I am very trigger happy when running around the wasteland. Since most things kill you in the first place it seems like a waste of time to think first. Shooting a friendly character usually makes them turn hostile and start attacking you. How do you stop a friendly character from attacking you if you attack them first, even if it is by accident?
There are 2 ways to stop a guard or any friendly NPC from attacking you after you attack them.
1) Die / Reload your last game save
This is the obvious option. Kill yourself or pause and reload and you will have reset any wrongdoings. If you haven't been in the habit of regularly saving the game a reload might not be a good idea. Thankfully the alternative allows you to keep playing without having to reload.
2) Play the waiting game
It seems that Fallout wasteland survivors have a very short memory. If you leave the area and return after 72 game hours have passed it will be like ye never had a fight. To speed it up you can fast travel to somewhere with a bed and do a whole load of sleeping to pass the time quickly. Once you have slept through 72 hours you can return to your previous location and the person who was trying to kill you will now be nice and friendly again.
Kinda sucks that this is the only way to get around accidentally attacking a friendly character in Fallout, but its all we have to work off. Could be worse, at least they do forgive you.