假设我正在本地计算机上的功能分支上工作。现在,在完成某些提交之后,我发出了拉取请求。
现在,假设我的请求请求已被接受,并且功能分支已合并到远程开发分支中。现在,在那之后我的本地要素分支发生了什么。它还会在我的本地系统上自动合并吗?还是我必须自己将其合并为devel?
如果我自己合并它,是否需要先执行git pull来更新本地开发分支?
答案 0 :(得分:0)
在功能完全开发之前,您始终会对功能分支进行更改。功能全面开发后,您将通过合并请求,然后检查您的更改是否正常。它们合并到开发分支中。创建拉取请求时,可以在用户界面中选择“接受拉取请求后删除源分支”,否则必须手动删除分支。
一旦分支合并,develop分支就会更新,但是在本地系统develop
中分支不会更新。因此,您将必须运行git pull
来更新您的开发分支。这不是自动的。
答案 1 :(得分:0)
让我用一个小例子来解释它。考虑一些远程存储库的初始设置。
build
您将reporting
分支远程合并到了# 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
分支上工作,并添加了另外两个commit,然后:
# 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
如果仔细查看以上布局,则两者相同。尽管它们的表示形式有很小的差异,但这是我有意向您解释合并概念的方法。
总而言之,这完全取决于您是否仍要在该分支上工作,或者您可以直接将其删除,因为在结束分支中,它只是指向git图上某些固定哈希的确定指针。