This is 'broken' because every command is entered into the history by default, as @suspectus has pointed out.
You can, however, instruct Bash to erase duplicates by setting the Bash variable
HISTCONTROL. (Documentation: http://www.gnu.org/software/bash/manual/bashref.html#Bash-Variables). It's a colon-separated list of zero or more keywords, the one you are most likely interested in being
erasedups. Note that only history entered in the current sessions is affected. Setting
HISTCONTROL=erasedups won't go back and erase duplicates from your former sessions (but do look below for another solution). Also note that
HISTCONTROL is a Bash variable and doesn't need to be exported.
For what it's worth, my settings are:
I started using these settings because I was annoyed by many trivial and duplicate commands pushing carefully crafted commands 'off the list'. The
HISTIGNORE setting ignores short commands. I find it's not much shorter to type 'Up Arrow' to retrieve a command like
ls, so I prefer not to store one- to three-letter commands at all. Also, anything starting with a space will not be stored in the history. I use this for throw-away commands.
Note that duplicates may still accumulate if you have multiple sessions open at the same time. From time to time, I remove duplicates from the history file with the following one-liner:
tac ~/.bash_history | awk '!seen[$0]++' | tac > .tmp.newhist && mv .tmp.newhist ~/.bash_history