DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Christophe Colombier
Christophe Colombier

Posted on • Updated on

my git aliases: amend and append

Here are now of my best git alias buddies:

[alias]
amend=commit --amend --edit
append=commit --amend --no-edit
Enter fullscreen mode Exit fullscreen mode
  • amend: add changes to last commit
  • append: same as amend without having a need to make change in the commit message

Here, I'm assuming the last commit is a local commit.

how to use them

Forgotten changes

let's say you need to send modification on two files, but you forgot one file.

So now last commit file A, and you need to add the change from file B

use git append path/fileb to add them to last commit.

Typo or forgotten things in the last commit message

Simply use git amend, the editor will be reopened.

Forgotten file

Let's now say, you added the changes and committed them, but you forgot a file that is not followed by git.

Simply add it with git add path/fileb then run git append (or amend if you want to add things to commit message)

how to set them up

If you want to add these aliases, run this:

git config --global alias.amend "commit --amend --edit"
➜ git config --global alias.append "commit --amend --no-edit"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›