git 在使用 --fixup 和 --autosquash 时让我很头疼。我想举两个例子,一个工作得很好,另一个是一团糟。(git 版本 2.6.2)
工作示例:
第一次提交:
$ git init
$ printf '1\n' > test.file
$ git add test.file
$ git commit -m 'Insert 1 --> first line'
$ cat test.file
1
Run Code Online (Sandbox Code Playgroud)
第二次提交(BUG):
$ printf 'This is\na BUG\n' >> test.file
$ git commit -am 'Added line 2 and 3 with BUG'
$ cat test.file
1
This is
a BUG
Run Code Online (Sandbox Code Playgroud)
第三次提交:
$ sed -i '2i 2' test.file
$ git commit -am 'Insert 2 --> second line'
$ cat …Run Code Online (Sandbox Code Playgroud)