Wednesday, October 31, 2012

git how to get all branches into existing local repo?

git how to get all branches into existing local repo?

Git: How to get all branches of remote repo into existing local repo, WITHOUT using git clone into a new directory? (Because you just want to get the diff, and not have to re-download every single thing -__-")


http://www.kernel.org/pub/software/scm/git/docs/git-clone.html

GIT URLS

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.
Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols. The following syntaxes may be used with them:
  • ssh://[user@]host.xz[:port]/path/to/repo.git/
  • git://host.xz[:port]/path/to/repo.git/
  • http[s]://host.xz[:port]/path/to/repo.git/
  • ftp[s]://host.xz[:port]/path/to/repo.git/
  • rsync://host.xz/path/to/repo.git/
An alternative scp-like syntax may also be used with the ssh protocol:
  • [user@]host.xz:path/to/repo.git/
The ssh and git protocols additionally support ~username expansion:
  • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
  • git://host.xz[:port]/~[user]/path/to/repo.git/
  • [user@]host.xz:/~[user]/path/to/repo.git/
For local repositories, also supported by git natively, the following syntaxes may be used:
These two syntaxes are mostly equivalent, except the former implies --local option.
When git doesn’t know how to handle a certain transport protocol, it attempts to use the remote-<transport> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:
  • <transport>::<address>
where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See git-remote-helpers(1) for details.
If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:


2
Git for human beings


3
http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git

If you have many remote branches that you want to fetch at once:
$ git remote update
$ git pull --all
Now you can checkout any branch as you need to, without hitting the remote repo.


But it doesn't seem to do what was asked... If you run those commands and then run "git branch" you will still only see the branches that you had to begin with. – infosec812 Oct 27 '11 at 17:13


4
http://stackoverflow.com/questions/6373277/git-sync-local-repo-with-remote-one

I'm a git noob so this might look like a silly question.
I have local & remote git repositories. I want to sync my local repository with remote repository so that my local repository becomes 100% copy of remote repository. Meaning that if certain files differ in these repos we override local ones with remote ones. And if there are files in local repos that do not exist in remote repo, local files get removed.
Is there a way to achieve that other than doing a fresh clone of remote repo?





7
what is git fetch
http://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch

In the simplest terms, git pull does a git fetch followed by a git merge.
You can do a git fetch at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).
git pull is what you would do to bring your repository up to date with a remote repository.


5
http://blog.mikepearce.net/2010/05/18/the-difference-between-git-pull-git-fetch-and-git-clone-and-git-rebase/

Git rebase

Finally, git rebase is pretty cool. Anything you’ve changed by committing to your current branch but are no in the upstream are saved to a temporary area, so your branch is the same as it was before you started your changes, IE, clean. It then grabs the latest version of the branch from the remote If you do ‘git pull –rebase’, git will pull down the remote changes, rewind your local branch, then replays all your changes over the top of your current branch one by one, until you’re all up to date. Awesome huh?

Finally..

If you get stuck, run ‘git branch -a’ and it will show you exactly what’s going on with your branches. You can see which are remotes and which are local. This is a good headsup before you start to break things! It’s worth remembering that git branches are basically just a pointer, so to be able to work with those commits you need a local branch which points to somewhere from which those commits are reachable.
Thanks to Ben for the extra stuff, clarifications and calling me an idiot when I get git wrong, because I am, as it’s really pretty simple, except for the simple.












No comments:

Post a Comment