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

Re: [PATCH] git-reset: allow --soft in a bare repo

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 14, 2007, 08:33 UTC
Message-ID
<7v7ip3jsf8.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070714052405.GA26107@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Ah, I hadn't thought of that. It seems a bit of a contortion, though,
> since git-branch is usually used for _making_ a branch, whereas
> git-reset is usually used for _changing_ a branch. But maybe that's just
> me.

"branch -f" is very often used to "reset the branch tip". My git day typically begins with "branch -f pu next".

Show 5 quoted lines
> At any rate, it might still be worth applying the patch. It should be
> harmless to loosen the restriction, and even if there are several ways
> to accomplish the same thing, why punish people who try git-reset first?
> On the other hand, this is the first time I've seen it come up, so maybe
> this isn't confusing people.

Actually, after thinking about this a bit more, I have become somewhat reluctant, as this might confuse new users by giving them a wrong mental model of what "reset" is about.

To my mind, as an old time git user, reset (any variant) has always been about reshaping the relationship among the HEAD, the index and the working tree; if there is no index nor the working tree (iow, a bare repository), there can be no "relationship" among them.

We initially had only --mixed and --hard (and the former was not even called --mixed as there were only two kinds). Then --soft was invented as a stop-gap measure before "commit --amend" came.

In all cases, the user is saying "I want to make the next commit I'll make on top of that commit (which may or may not be different from the HEAD), and I'd want to start working towards that goal, starting from such and such index and working tree state". And that "such and such state" is different among three variants:

 * "reset --mixed" means "I like what I have in the working
   tree, but I'd want to discard the index and start from what
   is in (possibly updated) HEAD instead";
 * "reset --hard" means "I want to restart both index and
   working tree from scratch, starting from (possibly updated)
   HEAD";
 * "reset --soft" means "I like what I have in the index and
   also I like what I have in the working tree -- do not touch
   them -- I want the next commit to go on top of that commit".

"reset --soft" happens to be a variant of reset that does not touch index nor working tree, but conceptually, "not touching" and "not having either is Ok" are two quite different things.

Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “git-reset: allow --soft in a bare repo”
  1. git-reset: allow --soft in a bare repoJeff King, Jul 14, 2007
  2. Junio C HamanoJul 14, 2007
  3. Jeff KingJul 14, 2007
  4. Junio C HamanoJul 14, 2007
  5. Jeff KingJul 15, 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.