How do I push amended commit to the remote Git repository?

后端 未结 16 1398
深忆病人
深忆病人 2020-11-22 04:42

When I\'ve worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the

16条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 05:05

    Here, How I fixed an edit in a previous commit:

    1. Save your work so far.

    2. Stash your changes away for now if made: git stash Now your working copy is clean at the state of your last commit.

    3. Make the edits and fixes.

    4. Commit the changes in "amend" mode: git commit --all --amend

    5. Your editor will come up asking for a log message (by default, the old log message). Save and quit the editor when you're happy with it.

      The new changes are added on to the old commit. See for yourself with git log and git diff HEAD^

    6. Re-apply your stashed changes, if made: git stash apply

提交回复
热议问题