Reputation: 203
I'm working with a git repo that has an empty master and multiple branches. When I do a git pull, it only seems to pull stuff down for the master but does not apply for the branches.
I find myself having to do git checkout branch; git pull
for each branch before I can push. Is there a command or switch I can use that does
Pull and apply changes to all branches and master?
Upvotes: 10
Views: 1298
Reputation: 91050
Your problem isn't with git pull
it's with git push
. Try setting up git to only push to the branch the current branch is tracking (if applicable):
git config --global push.default tracking
In the meantime, you are able to push whenever you want, but you'll get rejection notices for branches that wouldn't fast-forward on push. Those are quite often branches you aren't working on so don't much care about.
The above config will give you a bit more sensible behavior when you don't specify what to push.
Upvotes: 4
Reputation: 31025
I think there is no available command or switch because of what git pull
does - it fetches changes from remote (like git fetch
) and them merges changes to your current branch (git merge origin/master
or whatever your current branch tracks). Problem is not first part (actually git fetch
fetches changes for all remote branches) but merge - what should be done when you have merge conflicts? You can only merge on working copy, not on git objects. And when you start merging, then you need to abort it or resolve all conflicts and create merge commit.
Upvotes: 7