git: How to refresh a commit that isn't on top -
in working branch, have 3 dependent patches. of them not merged.
<commit id -1> <commit id -2> <commit id -3> how can add together new changes <commit id -2>?
currently here how doing it.
git stash git reset --hard head~1 git stash apply git add together . git commit --amend git cherry-pick <commit id -1> this working without problem. there improve way can commit staged files whichever commit want?
you can utilize interactive rebase , edit desired commit. like:
git rebase --interactive abc4321d^ in editor alter pick edit or e. apply changes (git stash pop) , commit them.
this way can modify multiple old commits in same run. go on rebase, , address next commit, use:
git rebase --continue at time, if sense did wrong, can cancel rebase using:
git rebase --abort please note rewriting public history (a history on repo shared others) bad habit. should rewrite previous commits if not yet published.
git git-commit amend
No comments:
Post a Comment