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.defaultdoesn’t return anything, that means, with “git 1.8.0.msysgit.0”, yourgit pushmeansgit push origin :, with the refspec ‘:‘ standing for “matching” branch.Here it creates a matching
branchAon the remote side.But that doesn’t make it a remote tracking branch.
In other word,
branch.branchA.mergeisn’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 pushshould have displayed the following message:So, with Git2.0, that git push will fail.
The only way to push
branchAwill be by setting explicitly its upstream branch (using the same name):