Hello, I used to 'git pull' in a branch and it was working without any questions asked. But now, if I do the following: git checkout -b test git pull I get a warning telling me that "You asked me to pull without telling me which branch ...". I would expect that my new local branch behaves the same way as the master branch. I am using 1.7.0.3 -- aghiles --
Heya, When you do this you're telling git "I want a new branch from where I am right now". If you want to be able to pull in a similar way to how master works, use the '--track' option. -- Cheers, Sverre Rabbelier --
This means that when pulling I will be pulling from the remote ? That is what I want to achieve. I just want all my branches to pull from the same remote (as my master branch does). Thank you for your help. -- aghiles --
Actually, the '--track' option is exactly what I don't want ! :) It tells me: "Branch test set up to track local branch refs/heads/master." Without the '--track' option it seems to work as expected: when I pull it downloads data form the remote but then stops before merging. This used to work! What happened ? :( -- aghiles --
Heya, See the --track documentation, you need to tell it to track upstream instead of master. -- Cheers, Sverre Rabbelier --
Read the doc. It is what you want, but you mis-use it. -- Matthieu Moy http://www-verimag.imag.fr/~moy/ --
I will read the doc, thank you for the advice. 'When creating a new branch, set up configuration to mark the start-point branch as "upstream" from the new branch.' So no, that's not what I want. Using : git branch test git checkout test git pull origin HEAD Is what I want and it works. BUT, I used to need only 'git pull' Again, the behavior changed since I last used this. No one cares? -- aghiles --
The behavior of Git did not change. The content of your configuration file or the branch you are on did. The way to put the right content in your configuration file is --track. When you create a branch, you say what the starting point of your branch is, and if you say --track, Git remembers it and uses it for pull next time. The simplest is to start your branch based on remotes/<name>/<branchname>, which is where your probably want to pull from. Otherwise, --set-upstream may help. But neither will help untill you RTFM. -- Matthieu Moy http://www-verimag.imag.fr/~moy/ --
Matthieu, I spend my days reading the git manual and also the source code, which is not normal IMHO. I always look for examples but in the case of 'git branch' there is not many that are really useful! I suggest to add this as an example since it is probably the most common case (one would expect that a new branch simply mimics the characteristics of the starting branch, no ?) git branch --track small_fixes origin And it does what I want. Again, the behavior changed: just upgraded to 1.7.0.3, before then I was doing branches like this: git checkout -b small_fixes git pull From my point of view, that was neat! The --track and <start-point>=origin seemed to be implied. I find that this is a better better default (OR 'git pull' was defaulting to 'git pull origin HEAD'). As of now, 'git branch x' seem to be of little use without more configuration. -- aghiles --
What was the old version of git? A long time ago (maybe 1.5.x or earlier?) we used to default unconfigured pulls differently. -Peff --
I don't have the information handy but it was most probably pre-1.5. I don't know if my 'branching habits' are common, but I found that the old behavior to be more natural with the way we work (creating branches for quick parallel work). If the current behavior is here to stay, I would humbly suggest to mention the 'git checkout -b x origin' syntax in the manual (and 'git branch --track x origin'). On a positive note, I would like to say that there is a good progress regarding the messages git prints to guide the user. That is helpful. -- aghiles --
OK, then the behavior did change for you. But you are probably about 3 It is in the checkout manual, but I think the subtlety that you missed is that "--track" is going to care about whether you start your branch from your local "master" or the remote "master". Even if they're at the same commit, you are interested conceptually in basing your work on what the remote is doing. Maybe we could talk about this in the definition of <start-point>, I guess. You may also be interested to know that "git checkout foo" these days when you have no "foo" branch will do the equivalent of "git checkout -b --track foo origin/foo", which would also do what you want. -Peff --
Dammit. :) But really no biggie. I just entered panic mode because I thought something got borked in my favorite tool, which is not the case Wouldn't that create/track a remote 'foo' branch ? I have no remote branches but only local ones so I am always tracking origin/master. -- aghiles --
Yes, it would, so I guess it doesn't help you. You should do "git checkout -b foo origin/master", then. -Peff --
>>>>> "Aghiles" == Aghiles <aghilesk@gmail.com> writes:
Aghiles> Using :
Aghiles> git branch test
Aghiles> git checkout test
Aghiles> git pull origin HEAD
I do this:
git checkout -b test origin/test
...
git pull
And it seems to work. It even announces that my test is tracking origin/test.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
--
Yes that syntax works too (although I use origin/master since I am tracking the main branch and not the remote "test" branch). Thank you very much. The message announcing the tracked branch is a nice touch. -- aghiles --
So, do I understand it right that there is still no canonical syntax to check out local branch tracking a remote one of the same name, without spelling out the branch name twice? -- Petr "Pasky" Baudis http://pasky.or.cz/ | "Ars longa, vita brevis." -- Hippocrates --
Only if you don't count Dscho's DWIM.
$ git checkout tr/word-diff
Branch tr/word-diff set up to track remote branch tr/word-diff from origin.
Switched to a new branch 'tr/word-diff'
--
Ugh. Right, so _this_ is what kept me from ever learning the proper way: (i) If you do `checkout B`, it will track remote branch B if it exists. (ii) If you do `checkout -b B`, it will never auto-track anything. (iii) If you do `git checkout -t -b B`, it will auto-track your current _local_ branch. This keeps getting me really confused, I hope I will remember it now for good, but I have seen others having trouble with this as well. I don't have immediate ideas that would do less harm than good to fix this up... perhaps except changing (iii) to auto-track the remote branch B if it exists and require tracked branch name if it doesn't - the current default seems pretty much useless to me for usual cases. (I can imagine a scenario where it would be useful, but not a common scenario where this would be useful default.) P.S.: The "--track without -b implies branch creation" sentence in git-checkout(1) seems to be plain wrong? -- Petr "Pasky" Baudis http://pasky.or.cz/ | "Ars longa, vita brevis." -- Hippocrates --
$ git branch -r origin/HEAD -> origin/master origin/html origin/maint origin/man origin/master origin/next origin/pu origin/todo $ git checkout -t origin/maint Branch maint set up to track remote branch maint from origin. Switched to a new branch 'maint' Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." --
Ah! I have not read all the gory details carefully enough. Wonderful, (iv) If you do `git checkout -t R`, it will track branch R, deriving local branch name B from it. -- Petr "Pasky" Baudis http://pasky.or.cz/ | "Ars longa, vita brevis." -- Hippocrates --
