当涉及到git的高级操作时,我更像是一个新手。我使用博客框架Octopress来维护我的博客。虽然Octopress自2011年以来没有任何开发,但它很好地满足了我的目的,所以到目前为止我还没有想过要改变任何东西。

仅供参考,我的博客托管在Github Pages上。

今天,在工作在一个新的帖子,git状态显示以下消息:

On branch source
Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

所有后续命令都重复相同的消息,如git add ., git commit -m 'message'和git push origin source。

这条信息是什么意思? 有什么东西坏了吗? 如果是,是什么? 我需要修理它吗?

如果可能的话,请给我一个pdf/网络文章,在那里我可以阅读这一点,并理解它的未来。

更多的细节:

bash-3.2$ git branch -a
* source
  remotes/octopress/2.1
  remotes/octopress/HEAD -> octopress/master
  remotes/octopress/gh-pages
  remotes/octopress/linklog
  remotes/octopress/master
  remotes/octopress/refactor_with_tests
  remotes/octopress/rubygemcli
  remotes/octopress/site
  remotes/origin/source

如果还需要更多信息,请告诉我。谢谢。


当前回答

使用以下命令删除本地分支

git branch -d branch_name

你也可以

git branch -D branch_name 

基本上强制删除(即使本地未合并到源)

其他回答

这可能会解决你的问题。

在做了更改之后,你可以提交它,然后

git remote add origin https://(address of your repo) it can be https or ssh
then
git push -u origin master

希望这对你有用。

谢谢

Actually torek told you already how to use the tools much better than I would be able to do. However, in this case I think it is important to point out something peculiar if you follow the guidelines at http://octopress.org/docs/deploying/github/. Namely, you will have multiple github repositories in your setup. First of all the one with all the source code for your website in say the directory $WEBSITE, and then the one with only the static generated files residing in $WEBSITE/_deploy. The funny thing of the setup is that there is a .gitignore file in the $WEBSITE directory so that this setup actually works.

足够的介绍。在这种情况下,错误也可能来自_deploy中的存储库。

cd _deploy

git branch -a
* master
remotes/origin/master
remotes/origin/source

在.git/config中,你通常需要找到这样的东西:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:yourname/yourname.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

但在您的情况下,分支管理员没有遥控器。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:yourname/yourname.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/*

你可以通过以下方法来解决:

cd _deploy
git branch --set-upstream-to=origin/master

所以,一切都像torek告诉你的那样,但可能需要指出的是,这很可能涉及到_deploy目录,而不是你的网站的根目录。

PS:使用带有git插件的shell(如zsh)来避免将来被这个东西咬伤可能是值得的。它将立即显示_deploy涉及不同的存储库。

对我来说,.git/refs/origin/master已经被损坏了。

我做了以下操作,为我解决了这个问题。

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

使用以下命令删除本地分支

git branch -d branch_name

你也可以

git branch -D branch_name 

基本上强制删除(即使本地未合并到源)

问题:你的分支基于“起源/主”,但上游已经没有了。

解决方案:git分支——unset-upstream