From: Johannes Sixt Date: Fri, 12 Mar 2010 06:57:33 GMT Subject: Re: How do you switch branches in a bare repo? Message-ID: <4B99E5DD.3020005@viscovery.net> In-Reply-To: <4B99DEA2.6050104@uq.edu.au> Adam Nielsen schrieb: > I want to remove some commits (with git reset) from a bare repo, but > they're not in the master branch and I can't figure out how to change > branches: > > $ git checkout newbranch > fatal: This operation must be run in a work tree > > I've tried running the reset locally and pushing the change (with -f) > but that doesn't work either, and Google isn't being much help. > > How do you switch between branches in a bare repo? You don't have to. This should work: git push -f . newbranch~2:newbranch will remove the last two commits at the tip of 'newbranch'. Of course, you can do the push from any other repository as long as you are allowed to do non-fast-forward pushes into the bare repository. -- Hannes