- Choose the commit to rebase up to (this will not include the commit in the rebase)
~/$ git rebase -i 4446727
- Depending on your editor, a screen with the following output will show up:
1 pick bc1ecf1 test: start mock service in setup file
2 pick ebc37e6 fix: use array destructuring, added type checking
3 pick bda6e77 refactor: DRY object creation with locale
4 pick badbd2f refactor: only use this package in a node env
5 pick f126e55 refactor: access `process.env` directly
6 pick 39ac182 fix: linting
7
8 # Rebase 4446727..39ac182 onto 4446727 (6 commands)
9 #
10 # Commands:
11 # p, pick <commit> = use commit
12 # r, reword <commit> = use commit, but edit the commit message
13 # e, edit <commit> = use commit, but stop for amending
14 # s, squash <commit> = use commit, but meld into previous commit
15 # f, fixup <commit> = like "squash", but discard this commit's log message
16 # x, exec <command> = run command (the rest of the line) using shell
17 # b, break = stop here (continue rebase later with 'git rebase --continue')
18 # d, drop <commit> = remove commit
19 # l, label <label> = label current HEAD with a name
20 # t, reset <label> = reset HEAD to a label
21 # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
22 # . create a merge commit using the original merge commit's
23 # . message (or the oneline, if no original merge commit was
24 # . specified). Use -c <commit> to reword the commit message.
25 #
26 # These lines can be re-ordered; they are executed from top to bottom.
27 #
28 # If you remove a line here THAT COMMIT WILL BE LOST.
29 #
30 # However, if you remove everything, the rebase will be aborted.
31 #
32 # Note that empty commits are commented out
Instead of pick
, change all of the values to edit
, or its shorthand value, e
. Save the file and it will take you back to the terminal.
- Once back in the terminal, you will see a similar command:
~/$ git rebase -i 4446727
Stopped at bc1ecf1... test: start mock service in setup file
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
From here, use the following commands to change the author:
~/$ git commit --amend --author="First Last <email@domain.tld>"
Followed by this output:
[detached HEAD bc1ecf1] test: start mock service in setup file
Date: Sat May 4 19:42:59 2019 -0400
5 files changed, 7 insertions(+), 32 deletions(-)
Then you can continue the rebase as long as there were no errors:
~/$ git rebase --continue
- This process will repeat until all the commits have been updated. You should see a message similr to the following:
Successfully rebased and updated refs/heads/my-branch.