Before when I installed Windows 10 when I press the arrow down or up button inside Git Bash I get my previous entered commands. But now when I have closed Git Bash i lose all the commands I have ever entered. How do I get this back?


2 Answers 2


Just enter exit inside the Git Bash console. It will add or update a .bash_history file.

  • 4
    Effectively it works, but I don't think is a good solution. Why when we close the window of git bash it doesn't update the .bash_history?
    – carmelolg
    Sep 24, 2018 at 8:44
  • 1
    You only have to do it once though. The next time you close the window it will save. Sep 24, 2018 at 11:24
  • 7
    I thought also, but if I don't type exit it don't save the history
    – carmelolg
    Sep 24, 2018 at 12:34
  • Or CTRL-D for fast exit also working.
    – dbreaux
    Feb 14, 2019 at 14:22
  • Observing that I lost my history because of an automatic Windows update & reboot as well :-(
    – dbreaux
    Feb 14, 2019 at 14:23

This is a duplicate and has already been answered: https://stackoverflow.com/a/10901227/5243543

Put this in your ~/.bash_profile

PROMPT_COMMAND='history -a'

  • You should check the link in this answer, was very helpful. Jul 31 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .