拉请求合并后怎么办



假设我正在本地计算机上处理一个功能分支。现在,在某些提交之后,我会发出一个pull请求。

现在,假设我的pull请求已被接受,并且特性分支已合并到远程的开发分支中。现在,在那之后,我的本地功能分支会发生什么。它会在我的本地系统上自动合并吗?还是我必须自己将其合并到devel中?

如果我自己合并它,我需要先做git pull来更新我的本地开发分支吗?

您总是对功能分支进行更改,直到您的功能得到完全开发。一旦功能完全开发完成,您就可以通过合并请求,然后如果您的更改看起来很好。它们被合并为开发分支。创建拉取请求时,可以在界面中选择"接受拉取请求后删除源分支",否则必须手动删除分支。

合并分支后,将更新开发分支,但在本地系统中不会更新develop分支。因此,您必须运行git pull来更新您的开发分支。它不是自动的。

让我用一个小例子来解释它。考虑一些远程存储库的初始设置。

# Your initial remote repository setup
hash1---hash2---hash3 <- origin/develop , origin/HEAD

# You checked things into your local then git copies would be:
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 <- origin/develop , origin/HEAD
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop , HEAD

# You create separate brach 'feature' out of it and add two commits to it:
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 <- origin/develop , origin/HEAD
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5 <- feature, HEAD

# You checked in remotely and raised pull-reqeust:
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 <- origin/develop, origin/HEAD

hash4---hash5 <- origin/feature 
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5 <- feature, HEAD

您将feature分支远程合并到develop中,这里的情况可能会很糟糕。有两种可能的结果:

  1. 快进合并<-最简单的一个
  2. 三向合并<-棘手的一个,不会发生在你的情况下。因此,暂时跳过它的解释

如果发生快进合并。当您没有得到任何合并冲突时,就会发生这种情况。就像,在这种情况下,您永远不会遇到,因为只有一个开发人员处于活动状态,并且只有一个分支处于签入状态。

# Fast-forward merge happens
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5 <- origin/develop, origin/HEAD, origin/feature 
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5 <- feature, HEAD

现在让我们假设,您继续在本地feature分支上工作,并添加了另外两个提交,然后:

# Added two more commits on local branch:
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5 <- origin/develop, origin/HEAD, origin/feature 
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5---hash6---hash7 <- feature, HEAD
# You checked local 'feature' branch's code in and raised a pull-request.
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5 <- origin/develop, origin/HEAD

hash6---hash7 <- origin/feature 
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5---hash6---hash7 <- feature, HEAD

# You merged local 'feature' branch's into develop branch.
## Your remote repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5

hash6---hash7 <- origin/develop, origin/HEAD, origin/feature
## Your local repository's snapshot would look like:
hash1---hash2---hash3 <- develop

hash4---hash5---hash6---hash7 <- feature, HEAD

现在,假设您将远程origin/develop更改合并到本地develop分支,然后:

## Your remote repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5

hash6---hash7 <- origin/develop, origin/HEAD, origin/feature
## Your local repository's snapshot would look like:
hash1---hash2---hash3 

hash4---hash5---hash6---hash7 <- <- develop, feature, HEAD    

如果你仔细观察上面的布局,那么两者都是一样的。虽然,它们的表示方式略有不同,但这就是我之前向您解释合并概念时所做的。

总之,这完全取决于你是否仍然想处理该分支,或者你可以简单地删除它,因为在最后的分支中只是一个指向git图上某个固定哈希的确定指针。

相关内容

  • 没有找到相关文章

最新更新