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

后端 未结 16 1648
深忆病人
深忆病人 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

    You are getting this error because the Git remote already has these commit files. You have to force push the branch for this to work:

    git push -f origin branch_name
    

    Also make sure you pull the code from remote as someone else on your team might have pushed to the same branch.

    git pull origin branch_name
    

    This is one of the cases where we have to force push the commit to remote.

提交回复
热议问题