4 ms·
I wish I could have both. Rebase to stick to single clean commit messages, but still preserve the history/order of modifications within that, even without the m
by crazygringo 14y ago
I wish I could have both. Rebase to stick to single clean commit messages, but still preserve the history/order of modifications within that, even without the messages.
I might work on a project for a week, write some code, do an intermediate commit, realize it's not needed, delete it. Then when I finally merge into master (rebase), that code I wrote is forever gone. Which I think is fine, but two months later I realize I could actually use it. But there's no way to get at it, is there? Or am I missing something?
- base698 14y agoOr am I missing something? That you can create arbitrary branches and keep them forever remotely or locally. If you think you'll need it branch off that point: git checkout -b branch_i_may_need then checkout the previous branch. a git log branch_i_may_need will always show the commit you needed at the top and git cherry-pick `git rev-parse branch_i_may_need` will cherry pick it into whatever branch you're on. That way you keep the commit and can still keep the remote repo clean.
- decklin 14y agoFYI, since (at least, IIRC) 1.7.2 that rev-parse is not necessary. You can even do `git cherry-pick ..branch_i_may_need` for multiple commits.
- simcop2387 14y agoYou can also avoid doing the two git checkouts by just doing "git branch branch_i_may_need" and you'll stay in your current one. I do that all the time, though i had no clue about git rev-parse. That's a great time saver.
- lotyrin 14y agoHe actually mentions this exact thing, but briefly. Keep your refs around. Branch to blah-wip, make whatever commits, then rebase and cleanup to blah. Maybe blah gets merged in, but blah-wip will still refer to whatever original history.