我对变基有点新意,而且之前肯定没有压制过。
当我签到我当地的一个名为'what'的分支时,然后我做了一个git add和git commit,然后进行了rebase。
我认为这是改造或至少一种方式的正确方法:
git rebase -i development
开发是我们的主线分支,我们重新提交我们的提交。当我执行该命令时,我得到:
我必须向下滚动以查看我刚刚尝试在开发分支之上重新设置的最新提交:
我不知道此时该做什么。在这一点上,我显然已经做出了改变,然后做了一个改变,所以有一个压缩的命令,我该怎么做?我不想压缩开发分支的整个历史吧?或者,在你重新定位之前,你会做什么?我迷失了一点。
答案 0 :(得分:0)
你应该能够改变单词" pick"到"壁球"为了压制标记为" squash"进入前面的提交。
Git Documentation: Rewriting History
一个例子:
$ 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:
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.
我改为:
# 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.