0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

リモートブランチを削除してローカルのブランチをpushする方法

Last updated at Posted at 2020-05-28

リモートのブランチ名を変えたいけれどあ゛~~~~~~ってなったので備忘録です。

リモートのブランチを表示します

$ git branch -r 
  origin/HEAD -> origin/master
  origin/master
  origin/fix_example

ローカルのブランチを表示します

$ git branch
* fix_example
  master

ローカルのブランチを書き換える必要が生じた!

$ git branch -m 5.fix_example

$ git branch
* 5.fix_example
  master

そのままpushしてもローカルのブランチ名は昔のまま

$ git push
fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:fix_example

To push to the branch of the same name on the remote, use

    git push origin HEAD

.git/config を編集します。

$ vim .git/config

編集前

~略~
[branch "5.fix_example"]
         remote = origin
         merge = refs/heads/fix_example

編集後

~略~
[branch "5.fix_example"]
         remote = origin
         merge = refs/heads/5.fix_example

揃えた。
あとはpushします。

$ git push

力技で解決系なので自己責任でお願いします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?