Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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_Rebase_Revision History - Fatal编程技术网

git重写历史(重新设置旧分支的基础?)

git重写历史(重新设置旧分支的基础?),git,rebase,revision-history,Git,Rebase,Revision History,到目前为止,我正试图在git存储库中重写我的历史,并取得了轻微的成功。 我试着在每次提交时使用重定基来删除巨大的文件,我一定是做错了什么,因为我最终得到了这个形状怪异的历史 * 0758bb3 - (HEAD -> master, origin/master, origin/HEAD) |\ | * 1ff4a51 | * f33555f (... a bunch of commits in the right-hand-size branch only) | * af4b7bf

到目前为止,我正试图在git存储库中重写我的历史,并取得了轻微的成功。 我试着在每次提交时使用重定基来删除巨大的文件,我一定是做错了什么,因为我最终得到了这个形状怪异的历史

*   0758bb3 - (HEAD -> master, origin/master, origin/HEAD)
|\  
| * 1ff4a51
| * f33555f
(... a bunch of commits in the right-hand-size branch only)
| * af4b7bf
| * a9bf8d0
| * f22fae8
* | 68bd9eb
* | 2e29133
|/  
* fbef4bf
我想将其转换为:

*   0758bb3 - (HEAD -> master, origin/master, origin/HEAD)  
* 1ff4a51
* f33555f
(...)
* af4b7bf
* a9bf8d0
* f22fae8
* 68bd9eb
* 2e29133
* fbef4bf
我想这样做的方式应该有点像

git checkout f22fae8
git rebase 68bd9eb
???
git push --force origin master
但考虑到我现在对“重定基期”了解甚少,我无法掌握现有信息来做到这一点。 我很抱歉,如果这个问题已经在某个地方得到了回答,我没有找到它(可能是因为我不知道应该用什么词来描述这个场景:/)。
非常感谢任何能帮我做这件事的人:)

我不知道你在上面想做什么。如果您合并了分支,并且它看起来像上面所示,那么您已经拥有了您要查找的内容。但是,如果您希望使用rebase使其看起来不同,那么您将有完全不同的提交。如果您正在重定基址,那么您基本上是在创建与以前存在的提交相同的新提交。那么提交历史就不一样了。下面是一个示例,它可以将上述结构转换为您正在寻找的内容,但需要新的提交

// First set up another branch where you can safely rebase

git checkout fbef4bf
git checkout -b rebase-point

// now switch to the place you want to rebase from:

git checkout master
git rebase rebase-point    

// if satisfied, set the master branch to point to the 0758bb3 commit equivalent (remember we are rebasing so it won't be the same commit).

git reset --hard rebase-point 

我不知道你想在上面做什么。如果您合并了分支,并且它看起来像上面所示,那么您已经拥有了您要查找的内容。但是,如果您希望使用rebase使其看起来不同,那么您将有完全不同的提交。如果您正在重定基址,那么您基本上是在创建与以前存在的提交相同的新提交。那么提交历史就不一样了。下面是一个示例,它可以将上述结构转换为您正在寻找的内容,但需要新的提交

// First set up another branch where you can safely rebase

git checkout fbef4bf
git checkout -b rebase-point

// now switch to the place you want to rebase from:

git checkout master
git rebase rebase-point    

// if satisfied, set the master branch to point to the 0758bb3 commit equivalent (remember we are rebasing so it won't be the same commit).

git reset --hard rebase-point 

重写公共分支(如提交散列更改)可以接受吗?如果是,则重新基址;如果不是,则只需执行分支合并。重写公共分支(如提交哈希更改)是否可以接受?如果是,则重新设置基础;如果不是,则只需执行分支合并。