Gitでブランチ名の先頭に「#」をつけてはいけない

f:id:nuakam:20180924103510j:plain:w500
なぜかPushができない問題

なぜかPushができない問題

greenkour.hateblo.jp

以前,↑の記事で軽く触れたましたが、Gitに送るとき毎度同じ方法を取っています。

git status

変更状況を確認

git add .

追跡に追加

git checkout -b ブランチ名

新しいブランチを切って、そこにチェックアウト

git push

PUSH!

すると怒られる

fatal: The current branch [ブランチ名] has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin [ブランチ名]

「この名前のブランチはリモートにないから、下のコマンド打ちなさいよ」


そのとおりに打ちます。

git push --set-upstream origin [ブランチ名]

あとはプルリクエスト→マージで終わり。一息つきます。


ちなみに豆知識。

git push --set-upstream origin [ブランチ名]

これは

git push -u origin [ブランチ名]

で省略できます。

問題発生

git push --set-upstream origin [ブランチ名]

これを叩いても何故か通らなくなりました。

何故か↓が出ます。

fatal: The current branch [ブランチ名] has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin [ブランチ名]

無限ループ。


解決


同じ問題にぶち当たった先駆者がいらっしゃいました。

qiita.com


なんでもCUIでは「#」文字をつけると、以下の文字列はコメントアウトとして認識するらしいです。

Gitの仕様では弾かれませんが、CUIの仕様で弾くようで。

""をつけると#も含めることができますが、基本的には#を先頭につけるのは避けましょう!