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

Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-)

From
ZZorba <cr@altmore.co.uk>
Date
Dec 30, 2008, 12:20 UTC
Message-ID
<gjd3lp$f1d$4@ger.gmane.org>
In-Reply-To
<3ab397d0812292133r7955e892g6c19ca46629e7103@mail.gmail.com>
> I have been using $ git reset --hard <version> as an escalator to ascend /
> descend the versions up and down
you should probably be using git checkout for this
> Surely it doesn't alter the history, as I can commit versionA, versionB,
> versionC, and then reset to A, then reset to C, then reset to B.

i does alter the history. i think this works because git isnt' deleting the actual blob objects in the git dir until you use the git prune, or gc or whatever (i never use it anyway). but, you are altering history, and just happen to be recovering.

** Ok!, so after commit B1, versionA doesn't store a link to versionB natively on and of its own accord. In other words BA and C are now written OUT of the history, as you say. I'm relying on some cached meta data that allows me to go back up the version tree again (ie downstream) and write B and/or C back into the history, which I should not rely on having access to all the time. Now I'm understanding more about differences between git-reset and git-checkout

> so when I reset to A, I've still got the ability to get to B or C again
with an uneasy conscience ;)

** yes, if the metadata cache failed or got wiped, I'd be screwed for getting back to later commits I see ! I'm relying on something that isn't part of the intrinsic design... hmmm

> Now I appreciate that if I commit a new change from versionA (lets call it
> B1), then HEAD is now at B1, and B, C etc are lost, correct ?

yes! but this is not true if you had done a git checkout (there are measures to recover B and C, provided you haven't done a prune. i think git reflog has some answers here, but i'm still a newbie).

Show 5 quoted lines
> Its pertinent to where I am right now, as I've goofed a commit, and want 
> to
> reset, and commit again but I'm worried about leaveing garbage lying 
> around
> (the commits for version B and C in the example above).

you've goofed what commit (a1?, c?, d3?)? where are you now and what do you want to do now? reset to what version? if you're just worried about space used by B and C, i think git prune will purge these (look at man page, don't guess at the syntax).

** I goofed B, so I reset to A, and redid the edits correctly this time (using your tip from other post $ git add -A = thanks again!), so now am on B1. Having read your notes, I am now comfortable about letting B and C hang around, as I realise now they are out of the official picture. Sitaram's comparison of a linked list helps since there is no branch/merge: B1 can only have one parent, which is A, so A can only have one child which is B1 (and B and C are relying on the cached stuff to survive, so let 'em freeze !)

i half suspect that you want to git branch at some point, but if yo'ure just recretaing the other code bases' history form other files, you shouldn't be able to break too much by git reset --hard, or git prune.

** yes I might well want to at some point, but don't want to run before walking. I'm the only one on this project currently, and still archiving old versions into git. When I get the latest one in, I may branch so I can work away without affecting a stable master branch.

Previous: Jeff WhitesideNext: Sitaram Chamarty
Message 6 of 21 in “for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-)”
  1. ZorbaDec 27, 2008
  2. ZorbaDec 28, 2008
  3. Jeff WhitesideDec 29, 2008
  4. ZorbaDec 30, 2008
  5. Jeff WhitesideDec 30, 2008
  6. ZorbaDec 30, 2008
  7. Sitaram ChamartyDec 30, 2008
  8. ZorbaDec 30, 2008
  9. ZorbaDec 30, 2008
  10. ZorbaDec 30, 2008
  11. Jeff WhitesideDec 30, 2008
  12. ZorbaDec 30, 2008
  13. Jeff WhitesideDec 30, 2008
  14. Daniel BarkalowDec 30, 2008
  15. ZorbaDec 31, 2008
  16. ZorbaDec 30, 2008
  17. Boyd Stephen Smith Jr.Dec 30, 2008
  18. Boyd Stephen Smith Jr.Dec 30, 2008
  19. Boyd Stephen Smith Jr.Dec 30, 2008
  20. Sitaram ChamartyDec 31, 2008
  21. Daniel BarkalowDec 30, 2008

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.