Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.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 rebase-i挤压_Git_Rebase - Fatal编程技术网

如何使用git rebase-i挤压

如何使用git rebase-i挤压,git,rebase,Git,Rebase,我对重定基址有点陌生,而且以前肯定没有压过提交 当我签出到我的本地分支“whatever”时,我会执行git add和git commit,然后重新设置基础 我想这是重新设置基础的正确方法,或者至少有一种方法: git rebase -i development 发展是我们的主线分支,我们在此基础上重新确定我们的承诺。当我执行该命令时,我得到: 我必须向下滚动以查看我刚刚尝试在开发分支上重新设置基础的最新提交: 现在我不知道该怎么办。在这一点上,我显然已经提交了我的更改,然后做了一个重基,所

我对重定基址有点陌生,而且以前肯定没有压过提交

当我签出到我的本地分支“whatever”时,我会执行git add和git commit,然后重新设置基础

我想这是重新设置基础的正确方法,或者至少有一种方法:

git rebase -i development
发展是我们的主线分支,我们在此基础上重新确定我们的承诺。当我执行该命令时,我得到:

我必须向下滚动以查看我刚刚尝试在开发分支上重新设置基础的最新提交:


现在我不知道该怎么办。在这一点上,我显然已经提交了我的更改,然后做了一个重基,所以有一个命令来挤压,我挤压什么??我不想把开发部门的整个历史都压扁,对吧?或者,在重新设定基准之前,您是否会进行挤压?我有点迷路了。

您应该能够将单词“pick”更改为“squash”,以便将标记为“squash”的提交压缩到前面的提交中

例如:

$ git log --oneline
acb05b3 Some final commit.
4968dbd Fixing an error in commit df89a81.
df89a81 Something committed too early.
c365eab Another commit...
625889f A commit...
70f29fd The beginning.
我想在最近一次提交之前重新设置3次提交的基础:

$ git rebase -i HEAD~3
这将在文本编辑器中提供以下文本:

pick df89a81 Something committed too early.
pick 4968dbd Fixing an error in commit df89a81.
pick acb05b3 Some final commit.

# Rebase c365eab..acb05b3 onto c365eab (3 command(s))
我将其改为:

pick df89a81 Something committed too early.
squash 4968dbd Fixing an error in commit df89a81.
pick acb05b3 Some final commit.

# Rebase c365eab..acb05b3 onto c365eab (3 command(s))
# This is a combination of 2 commits.
# The first commit's message is:

This is the squashed commit. It and everything after it get new commit hashes.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
退出后,我会得到另一个包含以下内容的编辑器:

# This is a combination of 2 commits.
# The first commit's message is:

Something committed too early.

# This is the 2nd commit message:

Fixing an error in commit df89a81.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
我将其改为:

pick df89a81 Something committed too early.
squash 4968dbd Fixing an error in commit df89a81.
pick acb05b3 Some final commit.

# Rebase c365eab..acb05b3 onto c365eab (3 command(s))
# This is a combination of 2 commits.
# The first commit's message is:

This is the squashed commit. It and everything after it get new commit hashes.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
现在,如果我看看我的新历史:

$ git log --oneline
8792fef Some final commit.
df775c4 This is the squashed commit. It and everything after it get new commit hashes.
c365eab Another commit...
625889f A commit...
70f29fd The beginning.

图像链接已断开。这是因为我更改了它,请再试一次。奇怪的是,我看不到列表中的所有选择,有没有办法向上滚动?缺少哪些提交,您当前的分支是什么,以及当前分支与分支
开发
有何不同
git-rebase-i开发
应该尝试对当前分支中尚未属于分支开发一部分的每个提交重新设置基础。因此,我签出到了“mybranch”。我做了两件事。而git提交。因此,我当地的分支机构有一些承诺。然后我在开发分支(不是我的分支)上做了一个重基。因此,当我重新设置基础时,我会在picah中看到开发分支的历史。好的,如果我向下滚动,我可以看到我的最新提交。我不知道为什么它一开始不会把我带到底部。我将添加另一个截图啊,这可能只是顺序造成了混乱。交互式重基列表按与git日志相反的顺序提交。即最老的第一个,最新的最后一个。