tags:

views:

129

answers:

2

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?

+5  A: 

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.

MBO
+1. It would be trivial to write a script to do it, of course.
ebneter
+2  A: 

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.

Dustin