让现有的Git分支跟踪远程分支? [英] Make an existing Git branch track a remote branch?
问题描述
我知道如何创建一个追踪远程分支的新分支,但如何让现有分支追踪远程分支?
我知道我可以编辑 .git / config
文件,但似乎应该有一个更简单的方法。
上游
: > 从Git 1.8.0开始:
git branch -u upstream / foo
或者,如果本地分支 foo
不是当前分支:
git branch -u upstream / foo foo
或者,如果您想输入更长的命令,这些命令就相当于以上两个命令:
git branch --set-upstream-to = upstream / foo
git branch --set-upstream-to = upstream / foo foo
自Git 1.7.0开始:
git branch --set-upstr eam foo upstream / foo
注释: 所有上述命令都会导致本地分支 I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch? I know I can just edit the Given a branch As of Git 1.8.0: Or, if local branch Or, if you like to type longer commands, these are equivalent to the above two: As of Git 1.7.0: Notes: All of the above commands will cause local branch See also: Why do I need to do `--set-upstream` all the time? 这篇关于让现有的Git分支跟踪远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
foo
跟踪远程分支 foo
从远程上游
。旧的(1.7.x)语法不赞成使用新的(1.8+)语法。新的语法旨在更直观,更易于记忆。 为什么我需要始终执行`--set-upstream`? .git/config
file, but it seems there should be an easier way.foo
and a remote upstream
:git branch -u upstream/foo
foo
is not the current branch:git branch -u upstream/foo foo
git branch --set-upstream-to=upstream/foo
git branch --set-upstream-to=upstream/foo foo
git branch --set-upstream foo upstream/foo
foo
to track remote branch foo
from remote upstream
. The old (1.7.x) syntax is deprecated in favor of the new (1.8+) syntax. The new syntax is intended to be more intuitive and easier to remember.