Git Bash: Clear History

The history -cw command is used to clear a Bash history on Linux, but for some reason it doesn’t work for a Git Bash on Windows.

If you try to clear the commands history in the Git Bash using this command, it won’t work – you will still see the history of the executed commands after the application restart.

To completely erase the Git Bash history you need to locate and delete the .bash_history file and then run the history -c command.

Cool Tip: How to change a Home (~) directory in Git Bash! Read More →

Clear Git Bash History

Run these commands in the Git Bash to locate and delete the .bash_history file:

User@Computer MINGW64 ~
$ echo $HISTFILE
- sample output -
/c/Users/<username>/.bash_history

User@Computer MINGW64 ~
$ rm /c/Users/<username>/.bash_history

User@Computer MINGW64 ~
$ history -c

Close the Git Bash window to finalize the erasing.

Cool Tip: How to change a default startup directory in Git Bash! Read More →

Was it useful? Share this post with the world!

3 Replies to “Git Bash: Clear History”

  1. Just what I was looking for. Thanks!

  2. It was very helpful

  3. I am working with git bash on windows 10 and the command history -c works fine without deleting .bash_history (March 23, 2023)

Leave a Reply