How can I avoid voltage spikes when connecting/disconnecting a 12v battery?
What is the equipment apart from a computer?

It should not be a vast issue if the load is not disconnected at any time. 

You should have spike protection already present sufficient to meet anything liable to arise. Substantial capacitance on battery lead. Small caps at regulator inputs. Maybe an inductive filter in battery lead. MOVs or similar on power lines do no harm. 

The exceedingly cautious may consider using a variable resistor or electronic equivalent to change batteries.  This should be overkill if all is designed well. 


Connect 2nd battery via a resistor that would drop about say 3V at full load current.   

Reduce resistor to zero.  

Hard connect 2nd battery.   

Add resistor set at 0 ohms from V+ to 1st battery +   

Break 1st battery direct connection.  

Increase resistor to max.   

Remove resistor