我跑了
$ git remote show origin
* remote origin
Fetch URL: XXX/client.git
Push URL: XXX/client.git
HEAD branch: (unknown)
Remote branches:
cancun tracked
cancun_elad tracked
dragon tracked
piano tracked
Local branches configured for 'git pull':
cancun_elad merges with remote cancun_elad
piano merges with remote piano
Local refs configured for 'git push':
cancun_elad pushes to cancun_elad (up to date)
piano pushes to piano (local out of date)
然后我跑了
$ git push
Counting objects: 710, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (146/146), done.
Writing objects: 100% (426/426), 5.57 MiB | 1.05 MiB/s, done.
Total 426 (delta 353), reused 324 (delta 266)
To XXXX/client.git
65c11e9..72b8931 cancun_elad -> cancun_elad
! [rejected] piano -> piano (non-fast-forward)
error: failed to push some refs to ' XXX/client.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.
这是否意味着我推动了 本地piano
和cancun_elad
?如果是这样,我该如何恢复piano
推送?
如何配置git push
只推送其中一个本地分支(cancun_elad
)?
push.default
在哪里?
答案 0 :(得分:0)
首先,除非您使用git push
(--force
)选项重新运行最后一个-f
,否则您应该没问题。虽然它尝试更新piano
,但实际上并没有这样做,因为它是非快进更新。
通常,设置push.default
的最佳位置在~/.gitconfig
。在这种情况下,我认为您正在寻找push.default
设置为upstream
。如果您有兴趣,git-config
手册页会提供有关其他值的更多信息。只需搜索push.default
。
您只需修改~/.gitconfig
并添加:
[push]
default = upstream
或者,运行:
git config --global push.default upstream
任何一个人都可以做到这一点。
注意:upstream
是文字upstream
,而不是您要跟踪的分支的名称。
:: git config --global push.default upstream
:: git config -l | grep push.default
push.default=upstream