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 make an .bash_history file.

  • 3
    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
  • 4
    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 alredy been answered: https://stackoverflow.com/a/10901227/5243543

Put this in your ~/.bash_profile

PROMPT_COMMAND='history -a'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.