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

Git push not showing new branch on remote

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

git checkout -b new_branch    

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

git commit -am "comments"    

然后推送到远程:

git push origin new_branch    

看起来成功了,我看到消息:

* [new branch]   new_branch -> new_branch    

然后我做:

git branch -a    

但我在 remotes/origin 下没有看到我的新分支,但我在本地看到了它。 我试试拉,

git pull    

和git表示一切都是"Already up-to-date"

我试过了

git fetch --all    

来自

的相同结果
git branch -a

我错过了什么?我不记得过去必须做任何不同的事情。

我希望能够执行以下操作:

git diff new_branch origin/new_branch

但是origin/new_branch没有出现 我所有的其他分支都显示为 remotes/origin/branchname

第一次推送分支时你应该做的:

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).

所有建议都指向远程仓库实际上具有正确的信息。由于远程回购的新克隆完美运行并显示了以前丢失的分支,因此该行为似乎来自某个损坏程度如何的本地回购。

感谢您的帮助。

感谢:

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