Created
October 20, 2015 08:35
-
-
Save MasayukiFukada/1ace6ec0e27ba9e42208 to your computer and use it in GitHub Desktop.
【備忘録】Gitのコミットを綺麗にまとめる色々な方法 ref: http://qiita.com/X___MOON___X/items/5b1910e952e07ad8bad6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 具体例) | |
| feature ブランチから feat/Proc1 を作成して作業していたが、push前に1つにまとめたい場合。 | |
| 1. まずは作業していたブランチをリネーム | |
| $ git branch -m feat/Proc1 feat/Proc1_hist | |
| 2. feature ブランチからコミットログの無い feat/Proc1 を新たに作成 | |
| $ git checkout feature | |
| $ git checkout -b feat/Proc1 // ブランチ作成と同時にチェックアウト | |
| これで | |
| * feat/Proc1_hist :コミットログが溜まっている作業ブランチ | |
| * feat/Proc1 :push用のブランチ(コミットログ無し) | |
| が出来る | |
| 3. feat/Proc1 に対して feat/Proc1_hist を squash でマージ | |
| $ git merge --squash feat/Proc1_hist | |
| ※ もし merge に --no-ff を設定していたら --ff も付ける | |
| 4. feat/Proc1_hist のコミットがまとめて stage されているのでコミット&push | |
| $ git commit | |
| $ git push origin feat/Proc1 | |
| ※ 作業が完了したら必要に応じて feat/Proc1_hist を削除。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment