3 ms·
Something I love to do with git: make temporary commits at the tip of a branch so I can checkout other branches without losing anything. I much prefer this to s
by macrael 9y ago
Something I love to do with git: make temporary commits at the tip of a branch so I can checkout other branches without losing anything. I much prefer this to stashes, generally. Stashes can still be useful to move changes from one branch to another, but generally I find changes make sense on the branch they were being written for.
> git commit -am "TMP COMMIT"
> git checkout ...
Once you switch back:
> git reset HEAD^
and you'll undo the temporary commit and be back to where you were.
- dpedu 9y agohttps://git-scm.com/docs/git-worktree https://git-scm.com/docs/git-worktree This doesn't exactly fit what you're asking for, but is an alternative workflow where you'll never need to do that.
- macrael 9y agoInteresting! Seems a bit heavyweight for most of what I use temporary commits for, but could be interesting if there were better tooling
- morsch 9y agoPart of my workflow as well. I do git reset --soft HEAD^ so that the changes from the previous session are still staged, which is occassionally useful.