Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 确保本地分支提交/推送到右侧远程分支_Git_Github - Fatal编程技术网

Git 确保本地分支提交/推送到右侧远程分支

Git 确保本地分支提交/推送到右侧远程分支,git,github,Git,Github,当我运行“git remote show guarddog”时,我希望看到如下内容: Local ref configured for 'git push': guarddoglocal pushes to master 然而,这实际上是我所看到的: git remote show guarddog Username for 'github.com': Password for 'github.com': * remote guarddog Fetch URL: https

当我运行“git remote show guarddog”时,我希望看到如下内容:

  Local ref configured for 'git push':
    guarddoglocal pushes to master
然而,这实际上是我所看到的:

git remote show guarddog
Username for 'github.com': 
Password for 'github.com': 
* remote guarddog
  Fetch URL: https://github.com/guarddog/guarddog.git
  Push  URL: https://github.com/guarddog/guarddog.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    guarddoglocal merges with remote master
显然,guarddoglocal没有配置为git推送到guarddog/master

这就是我到目前为止所做的:

git remote -v
origin  https://github.com/usera/usera.git (fetch)
origin  https://github.com/usera/usera.git (push)

git remote add guarddog https://github.com/guarddog/guarddog.git
git remote -v
guarddog    https://github.com/guarddog/guarddog.git (fetch)
guarddog    https://github.com/guarddog/guarddog.git (push)
origin          https://github.com/usera/usera.git (fetch)
origin          https://github.com/usera/usera.git (push)

git status
# On branch useralocal
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   app/assets/javascripts/application.js.erb

git push guarddog useralocal:master

git checkout -b guarddoglocal guarddog/master

git branch
* guarddoglocal
  useralocal

git status
# On branch guarddoglocal
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   app/assets/javascripts/application.js.erb

git remote show guarddog
Username for 'github.com': 
Password for 'github.com': 
* remote guarddog
  Fetch URL: https://github.com/guarddog/guarddog.git
  Push  URL: https://github.com/guarddog/guarddog.git
  HEAD branch: master
  Remote branch:
    master tracked
      Local branch configured for 'git pull':
        guarddoglocal merges with remote master

我认为您错误地使用了
-u
选项

git push -u guarddog      guarddoglocal:master
            ^^^^^^^^      ^^^^^^^^^^^^^ ^^^^^^
            remote name   local branch  remote branch

guarddoglocal
分支中,将配置它跟踪
guarddog
远程上的
master
分支。

该命令给了我错误:错误:src refspec master不匹配任何。错误:无法将一些参考推送到“我的坏,我忘记了一部分,现在就试试看,这很有效,但为什么我不能直接推git?”?当我运行“git remote show guarddog”时,它仍然显示推送在默认情况下未配置为推送到guarddog主远程。您知道如何配置它以便我只需要像克隆项目一样运行“git push”吗?好的,但当我运行git remote show时,它仍然没有说“为“git push”配置的本地引用:GuardGlocal推送到主控”。通常在克隆项目时,我会看到该部分。
git push -u guarddog      guarddoglocal:master
            ^^^^^^^^      ^^^^^^^^^^^^^ ^^^^^^
            remote name   local branch  remote branch