-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added last updated time in readme
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Editing Old Commits Using CLI or with Lazygit | ||
|
||
Whenever I needed to edit an old commit, be it a silly typo or a missing import I caught before pushing to a remote repository, I use the following `git` commands. | ||
|
||
```git | ||
git log # look up the commit hash to be edited | ||
git rebase --interactive 'abcdef^' # caret means its parent | ||
# mark the commit as "edit" and apply changes | ||
git commit --all --amend --no-edit | ||
git rebase --continue | ||
``` | ||
|
||
Using [lazygit](https://github.com/jesseduffield/lazygit), the process is almost identical. | ||
|
||
- Navigate to the commit to be edited and press `e` _(edit commit)_. | ||
- Stage changes and press `A` _(Amend commit with staged changes)_. | ||
- Press `m` _(view merge/rebase options)_ and select `continue`. |