Log.log(work)

いろんな作業メモ

Gitでうっかり違うメアドでコミットしちゃった件

なんか知らない人がコミットしているというのがばれないように後で修正する。

rebaseの魔法を唱える

$ git rebase -i HEAD~2

エディタが開いて、行頭に pick がついたリストが出てくるので、
修正対象を「edit」に修正して:wq。

すると修正チャンス到来。

$ git rebase -i HEAD~2
Stopped at xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... hoge
You can amend the commit now, with

        git commit --amend

Once you are satisfied with your changes, run

        git rebase --continue

メアドとユーザーを変更してコミット。

shinomiya@foo ~foo (branch|REBASE-i 2/2)
$ git commit --amend --author="user.name <user@example.com>"
[detached HEAD 0000000] hoge
 Date: Thu Jun 16 19:46:27 2016 +0900
 1 file changed, 18 insertions(+), 18 deletions(-)

あとはrebase --continue で残りのコミットを走らせる。

shinomiya@foo ~foo (branch|REBASE-i 2/2)
$ git rebase --continue
Successfully rebased and updated refs/heads/branch.