覚え書きブログ

gitの覚え書き(特定branchのpush)

gitのあるブランチでpushしようとしたら、以下のようなエラーがでた。

> git push
To https://github.com/hhachiya/SLAM-FasterRCNN.git
 ! [rejected]        depth_estimator_rpn -> depth_estimator_rpn (non-fast-forward)
error: failed to push some refs to 'https://github.com/hhachiya/SLAM-FasterRCNN.git'
ヒント: Updates were rejected because a pushed branch tip is behind its remote
ヒント: counterpart. If you did not intend to push that branch, you may want to
ヒント: specify branches to push or set the 'push.default' configuration variable
ヒント: to 'simple', 'current' or 'upstream' to push only the current branch.

どうやら、現在のブランチではなくて、他のブランチでrejectされているようだ。このように、git pushだけ実行すると、全てのブランチがpushされるので要注意である。
特定のブランチ、特に現在開発をしているブランチだけpushしたい場合は、以下のようにするとよい。

> git config --global push.default current
> git push