Git commands that I usually forget.
There are many
git commands that I use regularly, but not so often that I can actually remember them
so I’ve listed them here. I suspect that this list will probably grow over time.
Change an older commit message
- Run the following to show the last n commits in your editor.
$ git rebase -i HEAD~n
- Find the commits whose messages you want to change, and replace the command
- Save and exit.
The editor will now open for each commit in turn.
- Change the message, then save and exit.
If you need to push it, use the
Create an empty branch with no history
This is particularly useful when you need to create
$ git switch --orphan <branch_name>
Delete a remote branch
$ git push -d <remote_name> <branch_name>