我创建了一个跟踪分支,以便 whowasout.com 跟踪 whowasout.com/master

$ git remote -v
origin  git@github.com:venkatd/whowentout.git (fetch)
origin  git@github.com:venkatd/whowentout.git (push)
whowasout.com   git@git01.phpfog.com:whowasout.com (fetch)
whowasout.com   git@git01.phpfog.com:whowasout.com (push)


$ git branch -vv
  master        c33b5dc [origin/master] Merge branch 'whowasout.com'
* whowasout.com 7b6b240 [whowasout.com/master: ahead 1] print statement in test.
php

当我在 whowasout.com 分支中提交一些更改并执行“git Push”时,master 被推送到 origin/master。这是预期的行为吗?我原以为 whowasout.com 会推送到 whowasout.com/master。

为了推动我的更改,我目前输入“git push whowasout.com whowasout.com:master”,但我认为跟踪会让这个过程更快。我走在正确的轨道上吗?

有帮助吗?

解决方案

你必须这样做:

git push whowasout.com whowasout.com:master

这是因为 whowasout.com 没有分行 whowasout.com 而你不想要一个。你真正想要的是将本地的 whowasout.com 分支推送到远程的 whowasout.com 分支,这必须像上面那样完成。

为了得到你想要的行为,这样就 git push 从本地的 whowasout.com 分支推送到远程的 master,你必须设置 push.default 配置为 upstream (以前称为 tracking)

git config push.default upstream

请注意,您必须这样做,因为默认情况下,跟踪分支有助于在执行 fetch/pull 时跟踪上游分支。当您更改 push.default 设置中,它也会在推送中发挥作用。否则,推送只会推送匹配的引用,即 whowasout.com 分支将被推送到远程 whowasout.com 上的 whowasout.com 分支。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top