Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.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 pull中的所有提交之后,如何将本地提交移动到?_Git_Git Pull_Git Rewrite History - Fatal编程技术网

在git pull中的所有提交之后,如何将本地提交移动到?

在git pull中的所有提交之后,如何将本地提交移动到?,git,git-pull,git-rewrite-history,Git,Git Pull,Git Rewrite History,这是我的情况。我一直在开发一个功能,并进行了本地提交。我继续工作。与此同时,一位同事推动了我需要的变革。其中一些更改与我正在处理的文件相同 我目前有一些代码需要保存,然后才能从源代码中提取。 是否有办法提取代码,使同事的代码在提交历史记录中的最后一次本地提交之前存在? 我知道一个事实,我的本地提交比我将要提取的要老。 我将以这样的方式结束: older commit->my commit->origin commit 1->origin commit 2->popped stash 但我想要的是

这是我的情况。我一直在开发一个功能,并进行了本地提交。我继续工作。与此同时,一位同事推动了我需要的变革。其中一些更改与我正在处理的文件相同

我目前有一些代码需要保存,然后才能从源代码中提取。
是否有办法提取代码,使同事的代码在提交历史记录中的最后一次本地提交之前存在?
我知道一个事实,我的本地提交比我将要提取的要老。
我将以这样的方式结束:

older commit->my commit->origin commit 1->origin commit 2->popped stash

但我想要的是:

旧提交->源提交1->源提交2->我的提交->弹出的隐藏

我能看到的唯一方法是撤销我的本地提交,隐藏全部内容,然后拉出然后弹出隐藏内容。有没有一种方法可以维持我以前的承诺


我刚才看到这里有一个标记,用于
git rewrite history
,所以可能吗

您可以使用git
cherry pick
概念:

首先从
git log
输出中复制我的提交之前的
commit散列、
my commit
original-commit-1
original-commit-2

$ git log                 # First copy the commit hashes

$ git checkout -b b1      # create a new branch b1 (just for experiment)

$ git reset --hard <commit-hash-before-my-commit>

$ git cherry-pick <original-commit-1>
$ git cherry-pick <original-commit-2>
$ git cherry-pick <my-commit>
$ git stash pop
$git log#首先复制提交散列
$git checkout-b1#创建一个新的分支b1(仅用于实验)
$git重置--硬
$git樱桃精选
$git樱桃精选
$git樱桃精选
$git隐藏流行音乐

现在,
git log
应该显示您想要的提交历史记录

您可以使用git
cherry pick
概念:

首先从
git log
输出中复制我的提交之前的
commit散列、
my commit
original-commit-1
original-commit-2

$ git log                 # First copy the commit hashes

$ git checkout -b b1      # create a new branch b1 (just for experiment)

$ git reset --hard <commit-hash-before-my-commit>

$ git cherry-pick <original-commit-1>
$ git cherry-pick <original-commit-2>
$ git cherry-pick <my-commit>
$ git stash pop
$git log#首先复制提交散列
$git checkout-b1#创建一个新的分支b1(仅用于实验)
$git重置--硬
$git樱桃精选
$git樱桃精选
$git樱桃精选
$git隐藏流行音乐

现在,
git log
应该显示您想要的提交历史记录

撤消和重新应用一系列提交被称为
重基。要引入更改并重新设置基础,而不是合并,您可以使用
--rebase
选项:

git stash
git pull --rebase origin master
git stash pop

撤消和重新应用一系列提交称为
rebase
。要引入更改并重新设置基础,而不是合并,您可以使用
--rebase
选项:

git stash
git pull --rebase origin master
git stash pop

该死!我就知道!我只是不知怎么忘了。非常感谢!我就知道!我只是不知怎么忘了。非常感谢