git branch --set-upstream
2015-05-04 11:11
176 查看
一。使用场景: 本地新建一个分支后,必须要做远程分支关联。如果没有关联,git会在下面的操作中提示你显示的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支.
I create a new branch in Git:
git branch my_branch
Push it:
git push origin my_branch
Now say someone made some changes on the server and I want to pull from origin/my_branch. I do:
git pull
But I get:
You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull ').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "my_branch"]
remote =
merge =
[remote ""]
url =
fetch =
See git-config(1) for details.
I learned that I can make it work with:
git branch --set-upstream my_branch origin/my_branch
注意,推送到远程分支后,默认也不是跟踪snsconnct:mater分支,你只要没有显示指定,git pull的时候,就会提示你。
二。替代:
该语法等价与在第一次提交分支时,使用git push -u origin my_branch:
一种更简单的方式用来取代不好忘记的 git branch --set-upstream 是git push -u origin my_branch
在你第一次提交你的分支的时候使用。它会像git branch --set-upstream一样在本地分支与远程分去建立联系。
通常我们在新建分支的时候,一定要显式建立这种联系。
三。类似
this be equivalent to what is automatically done when you initially clone a repository
附:
下面部分就是git clone之后,添加到文件里的内容。感觉git clone主要是cline仓库。用来初始化。所以,它不能取代--set-upstream.
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
autocrlf = false
bare = false
[remote "origin"]
url = ssh://root@hostname/path
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "sns"]
remote = origin
merge = refs/heads/sns
或者
# git remote add origin ssh://...
now configure master to know to track
# git config branch.master.remote origin
# git config branch.master.merge refs/heads/master
and push
# git push origin master
四。命令的最终修改都是针对config文件。
使用--set-upstream去跟踪远程分支。
config在命令执行之前:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = root@****************
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "snsconnect"]
url = root@app220:/*******************
fetch = +refs/heads/*:refs/remotes/snsconnect/*
执行之后:
[branch "sns"]
remote = snsconnect
merge = refs/heads/sns
I create a new branch in Git:
git branch my_branch
Push it:
git push origin my_branch
Now say someone made some changes on the server and I want to pull from origin/my_branch. I do:
git pull
But I get:
You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull ').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "my_branch"]
remote =
merge =
[remote ""]
url =
fetch =
See git-config(1) for details.
I learned that I can make it work with:
git branch --set-upstream my_branch origin/my_branch
注意,推送到远程分支后,默认也不是跟踪snsconnct:mater分支,你只要没有显示指定,git pull的时候,就会提示你。
二。替代:
该语法等价与在第一次提交分支时,使用git push -u origin my_branch:
一种更简单的方式用来取代不好忘记的 git branch --set-upstream 是git push -u origin my_branch
在你第一次提交你的分支的时候使用。它会像git branch --set-upstream一样在本地分支与远程分去建立联系。
通常我们在新建分支的时候,一定要显式建立这种联系。
三。类似
this be equivalent to what is automatically done when you initially clone a repository
附:
下面部分就是git clone之后,添加到文件里的内容。感觉git clone主要是cline仓库。用来初始化。所以,它不能取代--set-upstream.
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
autocrlf = false
bare = false
[remote "origin"]
url = ssh://root@hostname/path
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "sns"]
remote = origin
merge = refs/heads/sns
或者
# git remote add origin ssh://...
now configure master to know to track
# git config branch.master.remote origin
# git config branch.master.merge refs/heads/master
and push
# git push origin master
四。命令的最终修改都是针对config文件。
使用--set-upstream去跟踪远程分支。
config在命令执行之前:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = root@****************
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "snsconnect"]
url = root@app220:/*******************
fetch = +refs/heads/*:refs/remotes/snsconnect/*
执行之后:
[branch "sns"]
remote = snsconnect
merge = refs/heads/sns
相关文章推荐
- GIT如何查看本地分支与远程分支的关联配置(git branch --set-upstream)
- Git新建本地分支与远程分支关联问题:git branch --set-upstream
- Git新建本地分支与远程分支关联问题:git branch --set-upstream
- Git新建本地分支与远程分支关联问题:git branch --set-upstream
- Git新建本地分支与远程分支关联问题:git branch --set-upstream
- git branch --set-upstream
- 解决git中upstream丢失问题Your branch is based on 'origin/xxxx', but the upstream is gone.
- git branch --set-upstream 本地关联远程分支
- git branch set-upstream master 分支名/master
- Git新建本地分支与远程分支关联问题:git branch --set-upstream【转】
- Git本地分支与远程分支关联问题(git branch --set-upstream-to=origin/<branch> )
- Git master branch has no upstream branch的解决
- git新建一个分支--set-upstream
- git branch --set-upstream develop origin/develop
- git:fatal the current branch master has no upstream branch
- git branch --set-upstream=origin/<branch> <local_branch>
- 解决Git建立远程分支关联时fatal the current branch master has no upstream branch 问题
- git:fatal the current branch master has no upstream branch
- git push 报错 -- set upstream origin master
- git branch --set-upstream 本地关联远程分支