Git推送不在远程显示新分支

时间:2015-01-29 14:56:43

标签: git

我创建了一个新的本地分支:

git checkout -b new_branch    

然后更改一些文件,并提交:

git commit -am "comments"    

然后推到远程:

git push origin new_branch    

看起来它有效,我看到消息:

* [new branch]   new_branch -> new_branch    
然后我做了:

git branch -a    

但是我没有在遥控器/原点下看到我的新分支,但我在本地看到它。 我试着拉,

git pull    

并且git说一切都是"已经是最新的"

我试过

git fetch --all    

来自

的结果相同
git branch -a

我缺少什么?我不记得过去不得不做任何不同的事情。

我希望能够做到这样的事情:

git diff new_branch origin/new_branch

但是origin / new_branch并没有显示出来 我所有的其他分支都显示为遥控器/ origin / branchname

2 个答案:

答案 0 :(得分:0)

第一次推动分支时,你应该这样做:

git push --set-upstream origin branch-name

如果你没有第一次这样做,你现在就可以做到。

-u, --set-upstream
  For every branch that is up to date or successfully pushed, add
  upstream (tracking) reference, used by argument-less git-pull(1) 
  and other commands. For more information, see branch.<name>.merge 
  in git-config(1).

答案 1 :(得分:0)

所有建议都指向远程仓库实际上有正确的信息。由于远程仓库的新克隆工作完美并显示以前缺少的分支,似乎行为来自一些损坏的本地仓库。

感谢您的帮助。

感谢:

I have seen this (and other strange) behavior before with Git. It is open source and no law says it will not have any bugs or quirks. When you did a <code>git pull</code> and everything was already up to date, that basically confirmed that the remote branch existed in the origin. – Tim Biegeleisen

相关问题