【问题标题】:GIT: fatal: 'master' does not appear to be a git repositoryGIT:致命:“master”似乎不是 git 存储库
【发布时间】:2015-07-01 01:52:18
【问题描述】:

我将我的主分支推送到我的 GIT 存储库并出现此错误

  fatal: 'master' does not appear to be a git repository

根据我输入的堆栈问题的建议

  git remote -v

得到了

  heroku    https://git.heroku.com/peaceful-cove-8372.git (fetch)
  heroku    https://git.heroku.com/peaceful-cove-8372.git (push)
  origin    https://github.com/SimonWalsh1000/breathe.git (fetch)
  origin    https://github.com/SimonWalsh1000/breathe.git (push)

然后我输入了

   simonalice$ git push -u origin master

它起作用了,但是说

   Branch master set up to track remote branch master from origin.

我对 GIT 很陌生,我不完全确定发生了什么。如果有人能向我解释这个序列,我将不胜感激。我一直无法得到明确的答案。我的主分支现在是 GIT 中的主分支还是克隆?

非常感谢

【问题讨论】:

  • 我的猜测是您最初运行了git push master,Git 将其解释为将当前分支推送到名为master 的远程的请求,而不是请求将分支master 推送到其默认遥控器。
  • 我认为你是对的。我怎样才能让一切恢复原状。根据上面的最后一个响应 - 分支主机设置为从源跟踪远程分支主机 - 这是否意味着我的计算机上的主机和 GIT 中的主机是同一回事?如果不是,我该如何补救?
  • 不,这只是意味着从现在开始(假设master 已签出),git push 的行为将类似于git push origin master。也就是说,除非您指定不同的远程,否则本地分支master 将被推送到origin。如果你愿意,你可以随时覆盖它,例如,git push heroku 推送到heroku 而不是origin。我认为您不需要解决任何问题。

标签: git git-push git-remote


【解决方案1】:

我在执行git pull <branch> 时遇到了同样的错误,我通过将其更改为git pull origin <branch> 来修复它。

【讨论】:

    【解决方案2】:

    它起作用了,但是说

    分支主机设置为从源跟踪远程分支主机。

    做一个 git config --local -l

    你会看到本地分支master设置为跟踪upstream branchorigin/master

    见“Difference between git checkout --track origin/branch and git checkout -b branch origin/branch”。

    就像你做的那样:

    git config branch.master.remote origin
    git config branch.master.merge refs/heads/branch
    

    第一个推送需要上游信息:参见“Why do I need to explicitly push a new branch?”。

    【讨论】:

    • 帮了很多忙(尤其是你的链接)
    猜你喜欢
    • 2011-11-11
    • 1970-01-01
    • 2020-06-10
    • 2023-04-05
    • 1970-01-01
    • 2012-06-09
    • 1970-01-01
    • 2020-01-20
    • 2021-07-28
    相关资源
    最近更新 更多