简体   繁体   English

提交到已合并的分支并打开新的拉取请求

[英]Commit to a branch that has been merged and open a new pull request

I have a branch A that has already been merged into master.我有一个已经合并到 master 的分支 A。 Now I need to add some new commits to the same branch A and open a new pull request.现在我需要向同一个分支 A 添加一些新的提交并打开一个新的拉取请求。 My question is if I commit to the same branch that was already merged, will the commits automatically go into master?我的问题是,如果我提交到已经合并的同一个分支,提交会自动 go 到 master 吗?

No, when you merge a branch, a new commit is created.不,当您合并一个分支时,会创建一个新的提交。 This commit only modifies one branch, namely the target branch.本次提交只修改了一个分支,即目标分支。 For instance:例如:

git checkout -b feature
# hack hack hack
git add changed files
git commit -m 'implemented my feature'
git checkout master
git merge --no-ff feature
# keep working on feature:
git checkout feature
# hack hack
git add changed files
git commit -m 'polished my feature'

You will have a new merge commit on branch master with 2 parents.您将在具有 2 个父级的分支master上进行新的合并提交。 You can then continue working on feature , create new commits and create new pull requests or merge requests.然后,您可以继续处理feature 、创建新提交并创建新的拉取请求或合并请求。 If you want the new commits to be part of master, you have to merge them again.如果您希望新提交成为 master 的一部分,则必须再次合并它们。 Git is smart enough to figure out which commits are new and which commits have already been merged before. Git 足够聪明,可以确定哪些提交是新的,哪些提交之前已经合并过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM