Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git rebase #54

Open
huangchucai opened this issue Dec 13, 2018 · 0 comments
Open

git rebase #54

huangchucai opened this issue Dec 13, 2018 · 0 comments

Comments

@huangchucai
Copy link
Owner

huangchucai commented Dec 13, 2018

rebase和merge的区别

场景

  1. 现在有2个分支,我们的开发分支feature和主分支master

  2. 我们在开发分支已经提交了部分内容

git-rebase1

  1. 这个时候,master分支有其他的功能提交
    image

rebase操作

  1. 我们切换到我们的开发分支git checkout feature
  2. 使用git rebase master进行合并

image

总结:可以看出我们在feature原来的提交会被删除掉,然后基于master分支的又重新开始新的提交了

**注意: **

  1. 永远不要在公共分支进行rebase的操作

  2. rebase的操作并不会改变master分支的内容,master分支还是在c7上,如果要发布上线提mr操作git checkout master git merge feature

image

merge

重回到我们上面的场景,我们使用merge合并

  1. 切换到主分支master分支git checkout master
  2. 合并我们的开发分支git merge feature

image

**总结: ** feature分支的提交不会被删除,和master分支的c6合并成一个新的内容,如果我们此刻基于master分支进行开发的话,就是在c7的位置进行开发

**注意: **

  1. master分支会被改动

git动画演示链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant