0

我创建了一个跟踪分支,所以 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”,但我认为跟踪会使这个过程更快。我在正确的轨道上吗?

4

1 回答 1

2

你将不得不做:

git push whowasout.com whowasout.com:master

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

要获得您想要的行为,以便git push从本地的 whowasout.com 分支推送到远程的 master,您必须将push.default配置设置为upstream(以前称为tracking

git config push.default upstream

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

于 2012-01-23T17:50:20.573 回答