撤消git在文件上更改
我做了几次投入并将它们推了下来,远程看起来像这样:
abcd ---...- n
commit b是4个修改后的文件(a,b,c,d)。我意识到我只想更改文件A,因此我需要丢弃B,C,D更改。问题在于我已经推动了该提交,并提出了更多的承诺。文件A在以后的提交中经常修改。 问题是当我单击Visual Studio 2022 =&GT时;管理分支=>还原,只有B和C文件更改已恢复,因此A和D仍然存在。我得到一个弹出窗口,说这是一个错误,但是输出窗口上没有什么。 问题是:如何使用git bash执行此操作?
I made several commits and pushed them so, remote looks like this:
A-B-C-D---...--N
Commit B is of 4 modified files (a, b, c, d). I realized that I only want changes in file a, so I need to discard b,c,d changes. The problem is that I have already pushed the commit and made more commits that I have pushed as well. File a has been modified a lot in later commits.
Problem is that when I click on Visual Studio 2022=> Manage branches => revert, only b and c file changes have been reverted, therefore a and d are still there. I get a pop up saying that it has been an error, but there is nothing on the output window.
Question is: how do I do this using git bash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用git bash,您可以找到提交的sha(使用GUI或
git log
),然后您只需启动git revert< sha>
这将创建一个新的提交,以恢复您在原始提交中所做的更改。
With git bash you find the sha of the commit (use a gui, or
git log
), then you simply launchgit revert <SHA>
This will create a new commit that revert the changes you made in the original commit.