Ответ 1
Вы хотите переустановить корневую фиксацию своего ветки master
. Более конкретно, чтобы сквош двух коммитов, вам нужно запустить
git rebase -i --root
а затем замените squash
на pick
на вторую строку в буфере редактора, который появляется:
pick 123456 a
squash abcdef b
Я отсылаю вас к git-rebase
странице man для получения дополнительной информации об этом флаге:
--root
Восстановите все коммиты, достижимые от
<branch>
, вместо этого их ограничения с помощью<upstream>
. Это позволяет вам переустанавливать root commit (s) на ветке. [...]
Пример интерактивной перезагрузки корня
# Set things up
$ mkdir testgit
$ cd testgit
$ git init
# Make two commits
$ touch README
$ git add README
$ git commit -m "add README"
$ printf "foo\n" > README
$ git commit -am "write 'foo' in README"
# Inspect the log
$ git log --oneline --decorate --graph
* 815b6ca (HEAD -> master) write 'foo' in README
* 630ede6 add README
# Rebase (interactively) the root of the current branch:
# - Substitute 'squash' for 'pick' on the second line; save and quit the editor.
# - Then write the commit message of the resulting commit; save and quit the editor.
$ git rebase -i --root
[detached HEAD c9003cd] add README; write 'foo' in README
Date: Sat May 16 17:38:43 2015 +0100
1 file changed, 1 insertion(+)
create mode 100644 README
Successfully rebased and updated refs/heads/master.
# Inspect the log again
$ git log --oneline --decorate --graph
* c9003cd (HEAD -> master) add README; write 'foo' in README