Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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_Merge_Gitlab_Git Merge - Fatal编程技术网

Git将两条提交消息合并为一条消息

Git将两条提交消息合并为一条消息,git,github,merge,gitlab,git-merge,Git,Github,Merge,Gitlab,Git Merge,我是GIT的初学者。我在我的工作项目中做了一些更改,并使用 git checkout -b 'test' 我提交了两次更改 git add . git commit -m "first commit" git push --set-upstream origin test 我再次做了一些更改并提交了更改 git add . git commit -m "second commit" git push --set-upstream origin test 现在我创建了拉取请求。我想要的是,我

我是GIT的初学者。我在我的工作项目中做了一些更改,并使用

git checkout -b 'test'
我提交了两次更改

git add .
git commit -m "first commit"
git push --set-upstream origin test
我再次做了一些更改并提交了更改

git add .
git commit -m "second commit"
git push --set-upstream origin test
现在我创建了拉取请求。我想要的是,我现在有两个承诺。当我合并到主分支中时,我不想看到这两条提交消息,我想将这些消息“first commit”和“second commit”合并到一条消息中,然后合并到主分支中


我尝试了rebase和rest命令。可能是我用错了。有人能帮我解决这个问题吗

如果要将最后两次提交合并为具有给定名称的一次提交

git reset --soft "HEAD^"
git commit --amend

由于您希望将两个提交合并为一个新分支作为单个提交,因此可以使用answer

假设您在自己的主题分支中。如果要合并 最后2个提交到一个,看起来像英雄,分支提交 就在你做出最后两次承诺之前

git结帐-b临时分支机构负责人^2

然后挤压并提交另一个分支 在这一新分支中:

git合并分支(带有两个提交)——挤压

这将带来 更改,但不提交更改。所以只要把它们交出来,你就完蛋了

git提交-m“我的消息”

现在您可以合并这个新的主题分支 回到你的主要分支

如果您只想在推送代码之前将两个提交合并到当前目录中的一个,那么使用answer

如果有多个提交,可以使用git-rebase-i压缩两个提交 一人一人

如果只有两个提交要合并,并且它们是 “最近两次”,以下命令可用于组合 二合一:

git重置--软“头^”

git提交--修改


可以肯定地说,这是一个副本,但我想让您拥有指向您正在寻找的答案的链接。

谢谢。。git提交后。。我需要再次推送分支吗?是的,如果需要更新github上的源代码,请确保github上的最后一次提交是您的,并使用git push--set upstream origin test--Force发生错误的原因是您试图重命名已推送到githubGood的提交,小心使用--force选项。如果您使用它推送,您将在github上获得与本地完全相同的提交