Add the following lines to your ~/.bashrc file:

shopt -s histappend

The first one sets the history to “append mode” rather than “over-write” mode and the second one appends each command to the history file immediately (rather than waiting until the end of your shell session to update it as it would normally do).