我做了什么:
$ git clone git@github.com:myuser/doctrine-extensions.git
$ cd doctrine-extensions
$ git checkout -b rollback_positions origin/master
然后我做了一些改变,承诺和状态说:
$ git status
On branch rollback_positions
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
现在我想将远程origin
推送到新分支rollback_positions
。但是Git不会创建新的远程分支,而是使用master
:
$ git push origin rollback_positions
Counting objects: 88, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 4.50 KiB | 0 bytes/s, done.
Total 17 (delta 10), reused 0 (delta 0)
To git@github.com:myuser/doctrine-extensions.git
b1c3643..6a09dc9 rollback_positions -> master
有什么问题?它应该是rollback_positions -> rollback_positions
。
答案 0 :(得分:0)
git checkout -b rollback_positions origin/master
将rollback_positions
的上游分支设置为origin/master
。您可以在推送时明确指定远程名称:
git push -u origin rollback_positions:rollback_positions
选项-u
将设置为上游。您还可以使用--set-upstream
和--unset-upstream
来更改upstream
。
为避免下次使用:
git checkout --no-track -b rollback_positions origin/master
正如Jubobs所说。