Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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_Github_Git Pull - Fatal编程技术网

Git拉旧提交

Git拉旧提交,git,github,git-pull,Git,Github,Git Pull,如何在存储库上的上一次提交中提取某些内容?我正在遵循一个指南,其中一半的代码已经过时,另一半则没有。因此,我需要将这一半数据发送回我本地文件中以前的状态。或者我应该使用收银台?我找到了我认为需要的提交,但我无法将其替换为我的文件。提前感谢。使用git log查找要回滚到的提交的SHA,然后: git checkout <SHA of commit> 完成更改。要将某些文件恢复到以前的状态(例如使用sha1 abc提交),可以执行以下操作 git checkout abc -- fi

如何在存储库上的上一次提交中提取某些内容?我正在遵循一个指南,其中一半的代码已经过时,另一半则没有。因此,我需要将这一半数据发送回我本地文件中以前的状态。或者我应该使用收银台?我找到了我认为需要的提交,但我无法将其替换为我的文件。提前感谢。

使用git log查找要回滚到的提交的SHA,然后:

git checkout <SHA of commit>

完成更改。

要将某些文件恢复到以前的状态(例如使用sha1 abc提交),可以执行以下操作

git checkout abc -- file1 file2 dir1
git commit -am "Rolled back some files"

这样做将在当前分支上添加一个新的提交,这些文件将处于旧状态。

您看到了吗?是的,我想我要做的是git pull的等效操作。这不是我的职责,我也不打算推动我的改变。
git commit --amend
git push origin master //Optional
git checkout abc -- file1 file2 dir1
git commit -am "Rolled back some files"