Вы можете сделать интерактивный перебаз с правкой:)
Перед тем, как вы нажмете (вероятно, вы хотите скрыть эту информацию;)), пожалуйста, подтвердите автор& commiter в git , чтобы не попасть в беду;)
Также учтите, что вы можете force push , если допустили ошибку.
Пример 2 коммитов:
* cd6b0ac (HEAD -> master) Fix test file
* e3e822e Add test file
Длинная версия (git log
)
commit cd6b0ac5a33283743f524463d0e78a2d3e335e4d (HEAD -> master)
Author: Bob <bob@git.com>
Date: Thu Nov 29 10:26:12 2018 +0000
Fix test file
commit e3e822e89397fdadbd1c6e1ac6710d96590d92c6
Author: Bob <bob@git.com>
Date: Thu Nov 29 10:25:53 2018 +0000
Add test file
Теперь я сделаю ребаз с правкой.git rebase -i e3e822e89397fdadbd1c6e1ac6710d96590d92c6
Теперь в консоли я увижу:
pick cd6b0ac Fix test file
# Rebase e3e822e..cd6b0ac onto e3e822e (1 command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
... (more I don't want paste)
Так что для этого коммита я выбираю e
и сохраняю-> quit.
e cd6b0ac Fix test file
ТакТеперь ваше рабочее дерево будет проверено для этого коммита.Теперь вам нужно сделать 2 шага:
git commit --amend --author="Dawid <dawid@git.com>"
git rebase --continue
перейти к следующему коммиту, который вы выбрали для редактирования или закончить перебазирование.
Теперь git log
для проверки
commit ec0949d075626ed9416d74c02bcbed721b8be2fe (HEAD)
Author: Dawid <dawid@git.com>
Date: Thu Nov 29 10:26:12 2018 +0000
Fix test file
commit e3e822e89397fdadbd1c6e1ac6710d96590d92c6
Author: Bob <bob@git.com>
Date: Thu Nov 29 10:25:53 2018 +0000
Add test file
Если вы хотите выбрать больше коммитов для перебазирования, вы можете написать такую вещь: git rebase -i HEAD^^
(выбрать последние 2 коммита)
Для проверкииспользуйте git log --pretty=full
commit ec0949d075626ed9416d74c02bcbed721b8be2fe (HEAD)
Author: Dawid <dawid@git.com>
Commit: Dawid <dawid@git.com>
Fix test file
commit e3e822e89397fdadbd1c6e1ac6710d96590d92c6
Author: Bob <bob@git.com>
Commit: Bob <bob@git.com>
Add test file
Читайте о git rebase
Другие вопросы по Simlar SO