git merge中的分支:与当前分支的关系,以及它们是否被git merge修改? [英] Branches in git merge: relation with the current branch, and whether they are modified by git merge?
问题描述
在 git merge
分支中,
-
分支是当前分支(即HEAD指向的分支?)?
-
当前分支是否称为目标分支,是另一个分支(es)是否被合并到目标分支?
li> -
目标分支是否始终未被指定为
git merge
,即我们只需要指定非目标分支(es )到git merge
?如果是,是因为目标分支始终是当前分支? -
合并期间当前分支没有命名约定,但是在这种情况下,主题分支被称为已经合并到当前分支中
-
只能指定要合并的分支 。合并发生的分支到总是当前分支
-
git合并仅更改当前分支。其他提交可以添加到
主题
分支中,并可以再次合并。
因此,将远程跟踪分支(称为只读)合并到当前分支是可以的,因为合并不会更改远程跟踪分支? (我正在阅读有关 git pull
中的合并步骤,它将远程跟踪分支合并到当前分支中,并且我记得远程跟踪分支是只读的) p>
git merge< topic>
该命令将主题
分支合并到当前分支,即当前由HEAD指向的分支
编辑:
远程追踪分支只读,它不包含工作目录。所以没有改变(读取提交)可以直接到远程分支。但是,您始终可以将更改推送到跟踪分支
因此,可以将远程跟踪分支合并到当前分支中。但是 git pull
中的 git merge
是可选的。您可以设置 git pull
来执行 git fetch
+ git rebase
如果需要的话。
In git merge
of branches,
must one of the branches be the current branch (i.e. the branch pointed by HEAD?)?
Is the current branch called the target branch, and is the other branch(es) said to be merged into the target branch?
Is the target branch always not specified to
git merge
, i.e. do we only need to specify the non-target branch(es) togit merge
? If yes, is it because the target branch is always the current branch?Does
git merge
change the target branch only, but not the other branch?So is it okay to merge a remote tracking branch (said to be read-only) to the current branch, because the merge does not change the remote tracking branch? (I am reading about the merge step in
git pull
, which merges a remote tracking branch into the current branch, and I remember a remote tracking branch is read-only)
You are right
git merge <topic>
This command will merge the
topic
branch to the current branch, i.e. the branch currently pointed to by HEADThere are no naming conventions for the current branch during merge, but yes, in this case, the topic branch is said to have merged into the current branch
Only the branch to be merged can be specified. The branch into which the merge happens is always the current branch
git merge changes only the current branch. Additional commits can be added to the
topic
branch and can be merged again.
EDIT:
A remote tracking branch is read-only in as much that it does not contain a working directory. So no changes(read commits) can be made directly to the remote branch. However you can always push changes to the tracking branch
So yes, it is okay to merge a remote tracking branch into the current branch. However the git merge
in git pull
is optional. You can set git pull
to do a git fetch
+ git rebase
if needed.
这篇关于git merge中的分支:与当前分支的关系,以及它们是否被git merge修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!