为什么分支似乎不是git存储库?它不是主分支

时间:2019-11-23 05:06:54

标签: bash git heroku

我不知道我做了什么更改git设置的配置。
当我使用'git push dev master'时,下面有一个错误,但是此指令之前有效。

$ git push dev master
fatal: 'dev' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这是我的存储库和分支机构的设置和配置

$ git remote -v
origin https://git.heroku.com/main_project.git (fetch)
origin https://git.heroku.com/main_project.git (push)

$ git remote show origin
* remote origin
  Fetch URL: https://git.heroku.com/main_project.git
  Push  URL: https://git.heroku.com/main_project.git
  HEAD branch: master
  Remote branches:
    backup                           tracked
    dev                              tracked
    development                      tracked
    master                           tracked
    refs/remotes/origin/fullcalendar stale (use 'git remote prune' to remove)
    repeat_reminders                 tracked
    stable                           tracked
    weekly                           tracked
  Local branches configured for 'git pull':
    dev    merges with remote dev
    master merges with remote dev
  Local refs configured for 'git push':
    dev    pushes to dev    (up to date)
    master pushes to master (up to date)

$ git branch -a
  dev
* master
  remotes/origin/backup
  remotes/origin/dev
  remotes/origin/development
  remotes/origin/fullcalendar
  remotes/origin/master
  remotes/origin/repeat_reminders
  remotes/origin/stable
  remotes/origin/weekly

我搜索了一些解决方案,例如'set-url'或添加了原点,例如以下
但是他们也不起作用。

git branch --set-upstream-to=origin/dev master

git remote add origin https://git.heroku.com/dev.git
fatal: remote origin already exists.

请帮助解决此问题。 非常感谢。

1 个答案:

答案 0 :(得分:1)

您要达到什么目标?首先,您设置了一个名为origin的遥控器。运行git push dev master时,您要让git将名为master的本地分支推送到名为dev的远程服务器上的同名远程分支。鉴于您只设置了origin,所以不要指望git能够遵守。如果要执行的操作是将两个分支(即dev和master)推到原始位置,则应运行:

git push origin dev master

如果您要执行的操作是将本地dev分支推送到远程master分支,则应该这样做

git push origin dev:master

还是您要尝试做其他事情?