LoginSignup
7
1

More than 5 years have passed since last update.

あるブランチの内容を別ブランチと同一にする

Last updated at Posted at 2018-12-14

背景

ブランチAの内容をブランチBと同一にしたい。
git checkout A && git reset --hard B でもできるが、そうすると git push --force が必要になってしまう。
ブランチAに対して1個追加コミットする形で、ブランチBと同一にしたい。

やり方

git checkout A
git checkout B .  # ブランチAのまま、Bの全ファイルをワーキングツリーにコピーする
git commit        # すでにインデックスに追加されているので、コミットするだけでOK

参考:
https://stackoverflow.com/questions/35174544/git-how-to-copy-contents-of-one-branch-to-other-branch

7
1
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
7
1