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

Re: Pushing into a repository with working directory?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 9, 2007, 03:32 UTC
Message-ID
<20070109033213.GC1904@spearce.org>
In-Reply-To
<7vd55pt3ts.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 9 quoted lines
> However, I am not sure if that is easy to understand for the
> users.  It would be sane to deny pushing into the current branch
> for a non-bare repositories by default, and if we do allow it
> (perhaps with 'git-push --force'), then detach the HEAD as you
> suggest.  On the other hand, pushing into the current branch of
> a bare repository should just work; the HEAD pointer in a bare
> repository is not about the commit the index and the working
> tree are based on, but which branch is the primary branch of the
> repository.

But from the working directory management tools' perspective HEAD *is* about the current index and the current working directory. If HEAD doesn't match the index and working directory closely enough then the user is going to do something stupid, like commit a negative delta by accident.

Pushing into the current branch of a repository with a working directory probably shouldn't be allowed by default as users probably don't want to do that. But if --force is used then detaching the HEAD is probably the best idea. The user could easily recover by doing `git checkout origbranch` (though they may need `git checkout -m origbranch` if their working directory was dirty).

-- 
Shawn.
Previous: Junio C HamanoNext: Andreas Ericsson
Message 9 of 11 in “Pushing into a repository with working directory?”
  1. Shawn O. PearceJan 2, 2007
  2. Andy WhitcroftJan 5, 2007
  3. Junio C HamanoJan 5, 2007
  4. Andy WhitcroftJan 5, 2007
  5. Junio C HamanoJan 5, 2007
  6. Shawn O. PearceJan 5, 2007
  7. Andy WhitcroftJan 8, 2007
  8. Junio C HamanoJan 9, 2007
  9. Shawn O. PearceJan 9, 2007
  10. Andreas EricssonJan 9, 2007
  11. Johannes SchindelinJan 9, 2007

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.