git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do you switch branches in a bare repo?

From
Adam Nielsen <adam.nielsen@uq.edu.au>
Date
Mar 12, 2010, 07:12 UTC
Message-ID
<4B99E957.60905@uq.edu.au>
In-Reply-To
<4B99E5DD.3020005@viscovery.net>
Show 10 quoted lines
>> 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.

Thanks for the suggestion! Unfortunately it looks like I'm not allowed to do non-fast-forward pushes into my own repository because I keep getting this error:

error: denying non-fast-forward refs/heads/newbranch (you should pull first)
  ! [remote rejected] newbranch~2 -> newbranch (non-fast-forward)

I tried using a + in front of the branch name as recommended by the manpage but it didn't change anything :-(

Any further suggestions?

Thanks again, Adam.

Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 8 in “How do you switch branches in a bare repo?”
  1. Adam NielsenMar 12, 2010
  2. Johannes SixtMar 12, 2010
  3. Adam NielsenMar 12, 2010
  4. Johannes SixtMar 12, 2010
  5. Adam NielsenMar 12, 2010
  6. Michael WittenMar 12, 2010
  7. Jonathan NiederMar 12, 2010
  8. Junio C HamanoMar 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.