为远程指定 git 分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4943827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
specifying git branch for remote
提问by Sig
I'm trying to update my webbynode pulling from github but I got the message below:
我正在尝试更新从 github 拉取的 webbynode,但收到以下消息:
You asked to pull from the remote '[email protected]:sigbackup/gsapp.git', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.
您要求从远程 '[email protected]:sigbackup/gsapp.git' 拉取,但没有指定分支。因为这不是您当前分支的默认配置远程,所以您必须在命令行上指定一个分支。
So I have checked out this forum for help and I found some comments regarding .git/config
file but mine looks already fine (at least to me):
所以我查看了这个论坛寻求帮助,我发现了一些关于.git/config
文件的评论,但我的看起来已经很好(至少对我来说):
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:sigbackup/gsapp.git
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "origin"]
remote = origin
merge = refs/heads/master
Am I missing something? Any ideas how I can solve it?
我错过了什么吗?有什么想法可以解决吗?
PS I also tried git pull origin [email protected]:sigbackup/gsapp.git
and I got
PS我也试过了git pull origin [email protected]:sigbackup/gsapp.git
,我得到了
fatal: Couldn't find remote ref [email protected]
致命:找不到远程引用 [email protected]
回答by silk
What local branch have you checked out?
你在哪个当地分行检查过?
What git status
shows?
什么git status
节目?
You are probably working on some other branch than the local master branch. If you want to fetch new commits from github and merge them to the local master branch, you have to:
您可能正在本地主分支以外的其他分支上工作。如果你想从 github 获取新的提交并将它们合并到本地 master 分支,你必须:
git checkout master
git pull
If you want those commits in the branch, on which you are working, you need:
如果您希望在您正在工作的分支中提交这些提交,您需要:
git pull origin master
You were close in your try from PS, but the last param should be branch name, not the repo url.
你在 PS 的尝试中很接近,但最后一个参数应该是分支名称,而不是 repo url。
You can also just fetch new commits from github, and do not merge it into any local branch, with:
您也可以只从 github 获取新提交,而不将其合并到任何本地分支,使用:
git fetch origin
Then review those changes with git diff
, git log
, etc, and merge later to the currently checked out branch with:
然后使用git diff
、git log
等检查这些更改,并稍后合并到当前签出的分支:
git merge origin/master
回答by ulidtko
It's strange that you have a branch called origin
. origin
is used to name a remoteautomatically created during git clone
; you will get in troubles having to disambiguate origin
-the-branch and origin
-the-remote. Did you add the branch manually to the .git/config
? What commands did you run? I suspect that you messed this up.
奇怪的是,您有一个名为origin
. origin
用于命名期间自动创建的遥控器git clone
;您将遇到必须消除origin
-the-branch 和origin
-the-remote歧义的麻烦。您是否手动将分支添加到.git/config
? 你运行了什么命令?我怀疑你搞砸了。