My computer name keeps changing when I plug it into a Thunderbolt display Every day I come into the office and plug my mac into my Thunderbolt display. It says the name "yourcomputer" is in use and renames it "yourcomputer-2" (or -3 or -4 ...). How do I make it stop?
Try making your hostname permanent by typing this command into the Terminal:

sudo scutil --set HostName yourcomputer


My hostname kept changing when I connected to the network because the router was broadcasting a different hostname, and this fixed it.