1

我跑了

$ 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.

这是否意味着我已经推动本地pianocancun_elad?如果是这样,我该如何恢复piano推送?

如何配置git push只推送一个本地分支 ( cancun_elad)?在哪里push.default

4

1 回答 1

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
于 2013-08-19T10:15:06.943 回答