Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get git to pull changes for all branches

Tags:

git

github

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?

like image 679
jnman Avatar asked Feb 11 '10 23:02

jnman


People also ask

Does git pull get changes from all branches?

git fetch. On its own, git fetch updates all the remote tracking branches in local repository. No changes are actually reflected on any of the local working branches.

How do I pull all changes in git?

To get all the changes from all the branches, use git fetch --all . And if you'd like to clean up some of the branches that no longer exist in the remote repository, git fetch --all --prune will do the cleaning up!

Does git pull pull all remote branches?

git fetch --all and git pull -all will only track the remote branches and track local branches that track remote branches respectively. Run this command only if there are remote branches on the server which are untracked by your local branches. Thus, you can fetch all git branches.


1 Answers

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.

like image 123
MBO Avatar answered Sep 23 '22 04:09

MBO