rebase作業で色々試した

一連のrebase作業の開始前

$ gloga

* 543010c (new-ci) [2020.07.29] brewでインストールしたcirclecivalidateでOK
| * e7c62c4 (HEAD -> ci-cd, origin/ci-cd) [2020.07.29] インデントを追加5
| * 958fbe8 [2020.07.29] インデントを追加4
| * 05cbca3 [2020.07.29] インデントを追加3
| * eb8ba8c [2020.07.29] インデントを追加2
|/  
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加



(1) 作業1 [コミットの入れ替え]

$ git rebase -i 57d3073
pick eb8ba8c [2020.07.29] インデントを追加2
pick 05cbca3 [2020.07.29] インデントを追加3
pick 958fbe8 [2020.07.29] インデントを追加4
pick e7c62c4 [2020.07.29] インデントを追加5

# Rebase 57d3073..e7c62c4 onto 57d3073 (4 commands)
#
# Commands:

# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit



コンフリクトの発生

$ git rebase -i 57d3073
Auto-merging .circleci/config.yml
CONFLICT (content): Merge conflict in .circleci/config.yml
error: could not apply 958fbe8... [2020.07.29] インデントを追加4

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

Could not apply 958fbe8... [2020.07.29] インデントを追加4

$ gloga
$ git status

interactive rebase in progress; onto 57d3073

Last commands done (2 commands done):
   pick eb8ba8c [2020.07.29] インデントを追加2
   pick 958fbe8 [2020.07.29] インデントを追加4

Next commands to do (2 remaining commands):
   pick 05cbca3 [2020.07.29] インデントを追加3
   pick e7c62c4 [2020.07.29] インデントを追加5
  (use "git rebase --edit-todo" to view and edit)

You are currently rebasing branch 'ci-cd' on '57d3073'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

    both modified:   .circleci/config.yml

no changes added to commit (use "git add" and/or "git commit -a")

$ 



手動修正

$ vim .circleci/config.yml

// コンフリクトマーカーの位置をvimで検索
/>


// 修正後
$ git add .

rebaseの継続

$ git rebase --continue

[2020.07.29] インデントを追加4

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# interactive rebase in progress; onto 57d3073
# Last commands done (2 commands done):
#    pick eb8ba8c [2020.07.29] インデントを追加2
#    pick 958fbe8 [2020.07.29] インデントを追加4
# Next commands to do (2 remaining commands):
#    pick 05cbca3 [2020.07.29] インデントを追加3
#    pick e7c62c4 [2020.07.29] インデントを追加5
# You are currently rebasing branch 'ci-cd' on '57d3073'.
#
# Changes to be committed:
#       modified:   .circleci/config.yml
#

コンフリクトの解消成功

Successfully rebased and updated refs/heads/ci-cd.



ひと作業終了後のlog (4と3の入れ替え)

$ gloga

* 0c789c3 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
* aa4c3b6 [2020.07.29] インデントを追加4
| * 543010c (new-ci) [2020.07.29] brewでインストールしたcirclecivalidateでOK
| | * e7c62c4 (origin/ci-cd) [2020.07.29] インデントを追加5
| | * 958fbe8 [2020.07.29] インデントを追加4
| | * 05cbca3 [2020.07.29] インデントを追加3
| |/  
|/|   
* | eb8ba8c [2020.07.29] インデントを追加2
|/  
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加
$ glog

* 0c789c3 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
* aa4c3b6 [2020.07.29] インデントを追加4
* eb8ba8c [2020.07.29] インデントを追加2
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加



(2) 作業2 rebaseによるコミットの削除

-1-2-3で、
2を削除すると
-1-「3'」
となることに注意

実行前

$ gloga
* 0c789c3 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
* aa4c3b6 [2020.07.29] インデントを追加4
| * 543010c (new-ci) [2020.07.29] brewでインストールしたcirclecivalidateでOK
| | * e7c62c4 (origin/ci-cd) [2020.07.29] インデントを追加5
| | * 958fbe8 [2020.07.29] インデントを追加4
| | * 05cbca3 [2020.07.29] インデントを追加3
| |/  
|/|   
* | eb8ba8c [2020.07.29] インデントを追加2
|/  
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加
$ glog

* 0c789c3 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
* aa4c3b6 [2020.07.29] インデントを追加4
* eb8ba8c [2020.07.29] インデントを追加2
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加

インデントを追加4を削除

$ git rebase -i 57d3073
pick eb8ba8c [2020.07.29] インデントを追加2
pick aa4c3b6 [2020.07.29] インデントを追加4
pick 0c789c3 [2020.07.29] インデントを追加5

# Rebase 57d3073..0c789c3 onto 57d3073 (3 commands)

コンフリクト発生

$ 

git add .

git rebase --continue

[2020.07.29] インデントを追加5

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# interactive rebase in progress; onto 57d3073
# Last commands done (2 commands done):
#    pick eb8ba8c [2020.07.29] インデントを追加2
#    pick 0c789c3 [2020.07.29] インデントを追加5
# No commands remaining.
# You are currently rebasing branch 'ci-cd' on '57d3073'.
#
# Changes to be committed:
#       modified:   .circleci/config.yml

そのまま「:q」保存。

Successfully rebased and updated refs/heads/ci-cd.

作業2後

$ gloga

* a0aab14 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
| * 543010c (new-ci) [2020.07.29] brewでインストールしたcirclecivalidateでOK
| | * e7c62c4 (origin/ci-cd) [2020.07.29] インデントを追加5
| | * 958fbe8 [2020.07.29] インデントを追加4
| | * 05cbca3 [2020.07.29] インデントを追加3
| |/  
|/|   
* | eb8ba8c [2020.07.29] インデントを追加2
|/  
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加
$ glog

* a0aab14 (HEAD -> ci-cd) [2020.07.29] インデントを追加5
* eb8ba8c [2020.07.29] インデントを追加2
* 57d3073 (origin/new-ci) [2020.07.29] インデントを追加
* 391e4a0 [2020.07.29] workflowsキーを追加
* f7ad220 [2020.07.29] circleci/config.ymlに3行追加



(3) 作業3 (インデントを追加2を削除)



(4) 作業4 (インデントを追加5のリネーム)

$ git rebase -i 57d3073
rewordに変更

エディタが自動起動

[2020.07.29] 一連のrebase作業の最新コミット

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Wed Jul 29 12:44:32 2020 +0900
#
# interactive rebase in progress; onto 57d3073
# Last command done (1 command done):
#    reword 97c1cf3 [2020.07.29] インデントを追加5
# No commands remaining.
# You are currently editing a commit while rebasing branch 'ci-cd' on '57d3073'.
#
# Changes to be committed:
#       modified:   .circleci/config.yml