summaryrefslogtreecommitdiff
path: root/3 Resources/Git/Edit existing commits.md
blob: 9832ee56217e0da9d16e5fc88f8327e6bc752cb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
tags:
  - git
---
I've found a nice and easy way to edit existing commits. Before I used the following "tedious" process.
```
git stash # Git rebase wants a clean working tree
git rebase -i <main|master|whatever branch your branched off>
... in the interactive editor, find the commit to edit, and mark it to edit ...
... write & quit ...
git stash pop # Optional. Only if you've already made the changes on HEAD.
git commit --amend
git rebase --continue
```

Now we can do something much easier using a so called "fixup commit".

```
git commit --fixup=<commit_id_to_fix>
git rebase -i --autosquash <main|master|whatever branch you branched off>
... write & quit
```