I don't know if I'm misusing Git, or if I've got a configuration problem.
I clone my Github repos onto machine A and B, then on machine A I do:
git checkout -b branchA
// make edits
git add .
git commit -am "initial"
git push
then on machine B I do:
git pull
git checkout branchA
// make edits
git commit -am "edits"
git push
on machine A I then do:
git pull
However it says:
There is no tracking information for the current branch
so I have to do:
git branch --set-upstream branchA origin/branchA
Why do I have to set the upstream, when it originally pushed it to origin/branchA without problem?
I'm using msygit 1.8. on Windows.
P.S. when i do the pull
on machine B, why isnt the new branch branchA
tracked by default? git branch
doesnt show it (but it does with -r
). Can I make all new remote branches be tracked by default when i pull?
since git config push.default
doesn't return anything, that means, with "git 1.8.0.msysgit.0", your git push
means git push origin :
, with the refspec ':
' standing for "matching" branch.
Here it creates a matching branchA
on the remote side.
But that doesn't make it a remote tracking branch.
In other word, branch.branchA.merge
isn't set to anything.
This is why the git pull fails: it doesn't know what remote branch it is supposed to merge to local branchA
.
Note, your first git push
should have displayed the following message:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
So, with Git2.0, that git push will fail.
The only way to push branchA
will be by setting explicitly its upstream branch (using the same name):
git push -u origin branchA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With