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?
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.
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!
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.
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.
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