Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
恢复Git拉动_Git - Fatal编程技术网

恢复Git拉动

恢复Git拉动,git,Git,我有一张Git提交图片,看起来像这样: (master)(origin/master)<---o | \ | \ | | | | | o--->commit D

我有一张Git提交图片,看起来像这样:

(master)(origin/master)<---o
                           | \
                           |  \
                           |  |
                           |  |
                           |  o--->commit D
                           |  |
                           |  |
                           |  o--->commit C
                           |  |
                           |  |
               commit B<---o  |
                           |  |
                           | /
               commit A<---o/
                           |
                           |
                    earlier commits
(主控)(原点/主控)提交D
|  |
|  |
|o--->commit C
|  |
|  |
提交B
我想没收C和D

您只需
git reset--hard HEAD~
就可以返回到上一次提交<代码>--硬
将放弃所有更改并为您提供一个干净的工作目录

谁能告诉我学习Git的更好方法是什么


继续使用它。经验是最好的老师。

你想同时更改Master和Origin/Master吗?是的,我想同时更改。在
HEAD
后面有什么数字吗?不,只要
git reset--hard HEAD
就行了。使用你的命令后,本地端现在看起来不错。但是源端呢?如果要放弃来自远程的提交,需要在执行重置后
git push-f
。请注意,其他任何人都可以通过按重新引入这些提交。如果其他人正在使用repository.Thx,您需要与其他人协调以删除这些提交。它起作用了。我觉得使用按需烹饪书食谱风格学习Git对我理解Git没有多大帮助。有什么我可以阅读来理解Git及其各种命令背后的思想/理念吗?
(master)(origin/master)<---o--->commit B
                           |
                           |
                           o--->commit A
                           |
                           |
                    earlier commits