本文介绍了Git:如何重新分割和压缩从分支到主的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重新绑定并将当前分支的所有提交压缩为主。这是我想要做的:

  git checkout -b新功能



做了一些提交,之后我尝试了:

  git rebase -i master 

在这种情况下,提交将保留在新功能分支

  git checkout master 
git rebase -i new -feature

它给了我和编辑窗口的noop消息。



我知道命令:

  git merge --squash new-feature 

但我目前正在学习 rebase 命令。

解决方案

重新绑定时,Git不会将提交移动到另一个分支。它将移动包含所有提交的分支。如果你想在提交到master后提交到master,使用 git merge<分支提示或提交分支> 来快速转发主分支到那个提交。


I'm trying to rebase and squash all my commits from current branch to master. Here is what I'm trying to do:

git checkout -b new-feature

make a couple of commits, after it I was trying:

git rebase -i master

in this case commits will remain in new-feature branch

git checkout master
git rebase -i new-feature

It gives me and edit window with noop message.

I know about command:

git merge --squash new-feature

But I'm currently working on learning of rebase command.

解决方案

When rebasing, Git will not move commits to another branch. It will move the branch including all its commits. If you want to get the commits into master after rebasing on top of it, use git merge <branch tip or commit of branch> to fast-forward the master branch to that commit.

这篇关于Git:如何重新分割和压缩从分支到主的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:56