Skip to content

Commit

Permalink
added: edit-old-commit.md
Browse files Browse the repository at this point in the history
added last updated time in readme
  • Loading branch information
byt3h3ad committed Nov 15, 2023
1 parent 8ffd0f3 commit 75d4232
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ jobs:
.sort()
.map(name => name.split("/").slice(-2));
// add last updated
const now = new Date();
readme += `\nLast updated: ${now.toDateString()}, ${now.toTimeString()}.\n`;
// add summary
readme += `\n${entries.length} TILs so far:\n`;
Expand Down
17 changes: 17 additions & 0 deletions git/edit-old-commit.md
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`.

0 comments on commit 75d4232

Please sign in to comment.