Git 恢复本地提交
我在 Windows 上的 phpstorm 中连接了一个 git 存储库。我提交了一些更改集,然后将它们推送到我们的“中央仓库”。在此之后,我又做了一些提交。我不再想要这些尚未推送到中央存储库的提交。如何清理我的工作副本以使其与中央存储库(来源)相同?
I have a git repo hooked up in phpstorm on windows. I committed a few change sets then pushed them to our "central repo". After this I have then made a few more commits. I no longer want these commits that have not been pushed to the central repo. How do I clean my working copy to be the same as the central repo (origin)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
比
/HEAD
更好,因为你不会看到这个:better than
/HEAD
because you won't see this:来恢复本地提交
您可以通过使用 N ,以恢复提交数量。一个例子:
如果您必须从本地恢复单个提交,那么您可以使用
或
git 重置 HEAD^
You can revert local commit by
where N is used to revert number of commits. An example:
if you have to revert single commit from local, then you can use
or
git reset HEAD^
如果您确信这一点并且没有任何本地未提交更改:
其中
origin/master
是您推送到的分支。引用日志仍将包含恢复的位,直到垃圾收集使它们过期。要恢复恢复,
If you feel sure about that and don't have any local uncommitted changes:
where
origin/master
is the branch you had pushed to.The ref-log will still contain the reverted bits, until a garbage collect expires them. To revert the revert,
根据我的理解,您创建了一些已推送到中央存储库的提交,之后您创建了更多提交,但这些提交存在于本地。这些都没有推动中央回购。
删除/恢复本地提交;
简而言之,您在命令提示符下点击 git log 并获取提交列表。看看您现在创建了多少提交以及需要恢复多少提交。
例如,您必须删除并恢复最后两次提交,然后点击
还有另一种方法可以使用中央存储库重置本地存储库。但是,在这种情况下,您的本地提交将被删除,如果其他用户在中央存储库上推送提交,那么您的存储库将随之更新。
命令是:
As per my understading, you create some commit that you have pushed on central repo, after that you have create some more commit, but these are exist on local. These all did not push on central repo.
To remove/revert local commit;
simply, you hit
git log
on your command prompt and get list of commits. Have a look, how many commit you have created now and how many you have to revert.for example, you have to remove.revert your two last commit then hit
There is one another way to reset your local repo with central repo. But, in this case your local commit will be removed and if other users push commit on central repo then your repo will be updated with that.
command is :