[英]How do I undo my committed and pushed changes to some of the tracking files in Git?
I am a newbie in Git. 我是Git的新手。 I did a mistake and now need to undo the same mistake.
我犯了一个错误,现在需要撤消相同的错误。 I cloned from a remote repository and that brought down fileA and fileB in my working directory.
我是从远程存储库克隆的,它在我的工作目录中关闭了fileA和fileB。 I made a commit and in that commit, I modified fileA and fileB from what is on the server.
我进行了提交,并且在该提交中,我从服务器上的内容修改了fileA和fileB。 (These changes shouldn't go to production).
(这些更改不应该投入生产)。
I also pushed the commit to a remote branch of the origin server. 我还将提交推送到原始服务器的远程分支。
Now I need to do two things: 现在,我需要做两件事:
How do I do this? 我该怎么做呢? Any help will be highly appreciated.
任何帮助将不胜感激。
If you need to undo the last commit and keep the changes then do reset
. 如果您需要撤消上一次提交并保留更改,请
reset
。
$ git checkout <your-branch>
$ git reset --soft HEAD~1 # undo last commits, and you've changes that you done.
now do change/fix
$ git commit -am 'new-message' # add & commit your changes
$ git push -f origin HEAD # force push to master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.