症状
Gitで新しいbranchを作成しコード修正後にgit pushをしたら、「fatal: The current branch fix-heroku has no upstream branch.」と怒られてしまいました。git checkout -b ブランチの名前
# 修正後
git add -A
git commit -m "コメント"
# pushしてエラー
git 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 fix-heroku
上記コマンドを日本語訳すると、
致命的:現在のブランチの分岐の名前には上流のブランチがありません
現在のブランチをプッシュしてリモートをアップストリームに設定するには、
git push --set-upstream origin fix-herokuをしてください
というものです。
解決方法
日本語訳する前に、commit→pushまでをやり直したら治りました。 上流ブランチが設定されていなかったためかと思われます。# マスターブランチにチェックアウト
git checkout master
# マスターに作ったブランチをマージ
git merge ブランチ名
# githubにプッシュ
git push
Gitについては知識不足であるので、研鑽していきたいです。
参考
事象 : プッシュしたらfatal: The current branch ブランチ名 has no upstream branch. https://qiita.com/ponsuke0531/items/410735b544795506fdc5#%E4%BA%8B%E8%B1%A1--%E3%83%97%E3%83%83%E3%82%B7%E3%83%A5%E3%81%97%E3%81%9F%E3%82%89fatal-the-current-branch-%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E5%90%8D-has-no-upstream-branchgit push --set-upstream origin masterって毎回聞かれるのをやめる
https://qiita.com/erii/items/e107b91a58f8250838da