I have a git repository with (at present) three branches:
head
is the stable version (not to be confused with gitHEAD
)experimental
is experimental code; it's supposed to compilenorman
is my sandbox; code in it might be broken
The "master" git repo is on a file server that is backed up. But I have replicas on a local disk, on a machine at home, and on my laptop. (I'm prepared to write code any time, any where).
git branch -a
shows:
experimental
head
* norman
tufts/HEAD
tufts/experimental
tufts/head
tufts/norman
the Tufts branches are the remote branches on the "master" repo. The local branches are supposed to track; git config -l | grep -w remote
says:
remote.tufts.url=linux.cs.tufts.edu:/r/ghc/git/experimental.git
remote.tufts.fetch=+refs/heads/*:refs/remotes/tufts/*
branch.experimental.remote=tufts
branch.head.remote=tufts
branch.norman.remote=tufts
Here's my question: how do I update all local branches from their remote counterparts simultaneously, using a single git command?
git-fetch
doesn't quite do the trick; it updates what it knows about the contents of each remote branch, but it doesn't merge them into the local. And apparently git-pull
updates only the currently checked out branch. I want to update all branches at once. Can it be done?
(I'm not wild about
for i in `git branch | sed 's/^.//'`; do git checkout $i ; git pull; done
partly because it's not obvious to me what happens to modified files in my working directory while all this is going on, and partly because I'd need yet more shell code to save and restore the info about what branch I'm currently on.)
I found one (not very closely related) question:
- About tracking remote branches