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

Operations on unborn branch

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Nov 27, 2012, 17:25 UTC
Message-ID
<CANiSa6isDKAgxHWqh5XiQ-adT3-ASFtvAshp028DTcotjQxzmQ@mail.gmail.com>

While looking at how to handle "git rebase --root", I noticed that "git cherry-pick" fails with the following when run on an unborn branch:

error: You do not have a valid HEAD fatal: cherry-pick failed

I can not see any reason that it shouldn't work. "git cherry-pick -n" does work. (For rebase, "git cherry-pick --ff" would be used, and I think that should also work on an unborn branch.)

Also, "git reset" doesn't work on an unborn branch and I can not see any reason that it shouldn't work. This was also asked on stack overflow [1], and of course the solution is to use "git rm --cached", but doesn't mean that "git reset" shouldn't work.

I have very limited time to work on git these days, so if anyone else would like to work on any of this, I would be very happy. I _might_ take some time to fix the cherry-pick issue.

Btw, every time I run into problems like these with the treatment of root commits, I can't help but wonder how things would look if git had always had a single root commit (naturally with some dummy user, timestamp etc to ensure sameness across repos). With my limited knowledge, it seems like that would complicate a few things, but simplify a lot of things (maybe I'm biased because of the things I have happened to work on?). Has anyone spent some time seriously thinking about this? I suppose it would be hard to introduce backward-compatibly, and maybe this is very unrealistic even for git 2.0, but I would be curious to hear what others think.

Martin
[1] http://stackoverflow.com/questions/3894808/new-git-repository-and-already-git-reset-does-not-work
Next: Junio C Hamano
Message 1 of 18 in “Operations on unborn branch”
  1. Martin von ZweigbergkNov 27, 2012
  2. Junio C HamanoNov 27, 2012
  3. Martin von ZweigbergkNov 27, 2012
  4. Junio C HamanoNov 28, 2012
  5. Martin von ZweigbergkNov 30, 2012
  6. 0/2 Fix "git reset" on unborn branchMartin von Zweigbergk, Nov 29, 2012
  7. 1/2 reset: learn to reset to treeMartin von Zweigbergk, Nov 29, 2012
  8. Junio C HamanoNov 29, 2012
  9. Martin von ZweigbergkNov 29, 2012
  10. Junio C HamanoNov 29, 2012
  11. Junio C HamanoNov 29, 2012
  12. Martin von ZweigbergkNov 29, 2012
  13. Martin von ZweigbergkNov 30, 2012
  14. Junio C HamanoDec 1, 2012
  15. Martin von ZweigbergkDec 5, 2012
  16. Junio C HamanoDec 5, 2012
  17. Martin von ZweigbergkDec 5, 2012
  18. 2/2 reset: learn to reset on unborn branchMartin von Zweigbergk, Nov 29, 2012

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.