Re: Trying to Update All Heads of a Repository
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:10
On Thu, 3 Nov 2005, Jon Loeliger wrote:
I don't know how to say "Grab all the updates for all the heads for which I have heads in my .git/refs".
Well, you can't per se - there's no guarantee that the heads on the other side match, and in fact usually they won't (at the very minimum, the remote "master" tends to be the local "origin", although if you never do any development at _all_, you can make even that match). I sent out a patch some time ago that added "--all" and "--tags", but only the "--tags" part was accepted. Arguably for good reasons. But "git fetch" will take a list of heads. So you can do git fetch repo master:origin pu todo and it will update the three local heads (origin, pu and todo) from the remote heads master, pu and todo respectively). IF you have a 100% match between heads names locally and remotely, you could also do something like git fetch repo $(cd .git/refs ; echo heads/*) which is pretty cheesy, but should work ;) As to your experiences with "git pull" - it should work fine too, but you really do need to make sure that the branch you are in always matches the branch you're pulling. Otherwise you'll be doing a merge between two different branches - which is a valid operation, but not what you're trying to achieve here. As we saw earlier, the way to undo an unsuccessful "git pull" is to do a "git reset --hard". Undoing a _successful_ git pull is actually slightly harder in the general case (it's really undoing a series of commit), but if you do it right after the pull, you can do git reset --hard ORIG_HEAD because "git pull" will save the original head before pulling. Linus