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

Re: Why is pushing to stash not allowed without an initial commit?

From
Sergey Organov <sorganov@gmail.com>
Date
Oct 17, 2024, 20:50 UTC
Message-ID
<87msj2a1xy.fsf@osv.gnss.ru>
In-Reply-To
<ZxFe/cEI0SzFMSi0@nand.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 19 quoted lines
> On Thu, Oct 17, 2024 at 08:51:29PM +0530, Abhijeet Sonar wrote:
>> I see that the stash commit has two parents: the initial commit and the
>> commit that actually holds the files that were stashed.
>>
>> If git were to allow a stash entry with no initial commit, it would have to
>> create a stash commit with only one parent (i.e. the commit labeled with
>> 'index on <branch>'). I wonder if there is a reason this would be bad and
>> therefore not allowed?
>
> Right, each stash entry has two parents:
>
>   - The first parent is the state of HEAD in your repository when you
>     created the stash entry,
>
>   - The second parent is the state of the index at the same point
>
> So there would be no reasonable value to substitute in for the first
> parent in the case where your repository does not yet have any
> commits.

I still wonder why Git has no concept of the ultimate null-commit from which all the Git world descends? Looks like it'd help to have one to handle such corner cases gracefully. Was it just an oversight of original design that isn't worth fixing already?

-- 
Sergey
Previous: Taylor Blau
Message 3 of 3 in “Why is pushing to stash not allowed without an initial commit?”
  1. Abhijeet SonarOct 17, 2024
  2. Taylor BlauOct 17, 2024
  3. Sergey OrganovOct 17, 2024

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.