3 ms·
> I fairly often make a branch as a sort of named undo point Could you say more about this? I use git checkout -b new-branch all the time, but that checks
by dreamcompiler 6y ago
> I fairly often make a branch as a sort of named undo point
Could you say more about this? I use
git checkout -b new-branch
all the time, but that checks it out. What does "using an un-checked-out branch as an undo point" mean? Don't you have to check it out to commit changes to it? I suppose I could read the docs but the git docs are awful.
- hellofunk 6y agoIt creates the branch immediately for your last commit on your current branch. Therefore you have just named an undo point you could use later.
- bacon_waffle 6y agoOccasionally I find it handy to tentatively do a rebase or similar, where I'm confident that the rebase itself will succeed but not so confident that the result will be something that I want to keep. In that case, making a branch at the current commit (using "git branch new-undo-point") will leave an easy way to return to the current state as if the rebase never happened. Recently, in explaining this to a colleague who's relatively new to git, I think the "aha" moment came in realising that if you rewrite the history leading to commit X, you're really making new commit Y in addition to the old commit X - you're not changing X in to Y. Leaving a branch pointing at X is enough that git will keep it around after the history rewriting, in case you decide to do something with it later.
- dreamcompiler 6y agoAh. I get it. You're talking about using a new branch name as a tag for an existing commit. Thanks.
- deleted 6y ago[deleted]