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

后端 未结 16 1654
深忆病人
深忆病人 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 04:50

    If you know nobody has pulled your un-amended commit, use the --force-with-lease option of git push.

    In TortoiseGit, you can do the same thing under "Push..." options "Force: May discard" and checking "known changes".

    Force (May discard known changes) allows the remote repository to accept a safer non-fast-forward push. This can cause the remote repository to lose commits; use it with care. This can prevent from losing unknown changes from other people on the remote. It checks if the server branch points to the same commit as the remote-tracking branch (known changes). If yes, a force push will be performed. Otherwise it will be rejected. Since git does not have remote-tracking tags, tags cannot be overwritten using this option.

提交回复
热议问题