如何将新的本地分支推送到远程Git存储库并进行跟踪? [英] How do I push a new local branch to a remote Git repository and track it too?
问题描述
我希望能够做到以下几点:
-
创建基于其他一些本地分支(远程或本地)分支(通过
git branch
或git checkout -b
) -
将本地分支
推送到远程存储库(发布),但将其作为
可跟踪的,以便git pull
和git push
将立即生效。 / p> Create a local branch based on some other (remote or local) branch (via
git branch
orgit checkout -b
)Push the local branch to the remote repository (publish), but make it trackable so
git pull
andgit push
will work immediately.
我知道Git 1.7中的 - set-upstream
,但这是一个后期创建操作。我希望找到一种方法在将分支推送到远程存储库时进行类似的更改。
在Git 1.7.0以后,你可以签出一个新的分支:
git checkout -b< branch>
编辑文件,添加并提交。然后使用 -u
(简写为 - set-upstream
)选项:
git push -u起源<分支>
Git会在推送期间设置跟踪信息。
I want to be able to do the following:
How do I do that?
I know about --set-upstream
in Git 1.7, but that is a post-creation action. I want to find a way to make a similar change when pushing the branch to the remote repository.
In Git 1.7.0 and later, you can checkout a new branch:
git checkout -b <branch>
Edit files, add and commit. Then push with the -u
(short for --set-upstream
) option:
git push -u origin <branch>
Git will set up the tracking information during the push.
这篇关于如何将新的本地分支推送到远程Git存储库并进行跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!