Reputation: 14439
Is it possible to reset branch that is not currently checked out?
I want to create a cron script that will perform git svn fetch
and then update all local branches tracking svn remote branches with new changes.
Upvotes: 1
Views: 357
Reputation: 76296
Sure, easily.
git update-ref -m "message" refs/heads/whatever new-value old-value
The message is whatever you want to appear in reflog. You can omit that.
The old-value
is there to avoid race-conditions. It checks that the ref still has that value before the update, so if another script updates it while you are processing it, the operation will fail. If you don't have risk of race-conditions, you don't have to specify it.
You of course have to know what you are doing. Take care not to drop any important revisions there.
You also must not do this to the checked-out branch. It might be most useful to avoid having any branch at all checked out by doing git checkout HEAD@{}
. That will make the special ref HEAD
store the commit ID directly, you can update any ref and than you can come back and git checkout
whatever you want.
Upvotes: 2