3 ms·
Whenever I'm pulling down code, instead of `git pull', I use fetch. I fetch the specific branch into the local remote tracking branch (remote/branchname). Then
by syncerr 14y ago
Whenever I'm pulling down code, instead of `git pull', I use fetch. I fetch the specific branch into the local remote tracking branch (remote/branchname). Then use rebase, rather than merge. I won't lose anything and it avoids those dumb merge commits. Also, aliases are great for this.
git fetch <remote> <branchname>:refs/remotes/<remote>/<branchname>
git rebase <branchname> <remote>/<branchname>
- kemayo 14y agoThat's equivalent to just doing `git pull --rebase`, no?
- syncerr 14y ago`git pull --rebase` does not update my remote tracking branch. Though you may not care about this.
- __david__ 14y agoThe "git pull" man page states that "git pull --rebase" is exactly equivalent to "git fetch" followed by "git rebase" so I'm not sure why it wouldn't update your remote tracking branch (since that is what "git fetch" does).
- tingletech 14y agoI never knew of the local remote tracking branches in git until now. I just went and looked it up and found this post that explains it more http://longair.net/blog/2009/04/16/git-fetch-and-merge/ http://longair.net/blog/2009/04/16/git-fetch-and-merge/ git branch -r will show all the remote tracking branches I had no idea existed. Thanks a lot, git makes much more sense to me now.