A fork can occur when a blockchain diverges into two potential paths forward, there is a change in protocol, or a scenario occurs in which two or more blocks have the same block height.
Because blockchain networks are decentralized, the participants on the network must come to an agreement when it comes to things like software upgrades to a network. This is called consensus.
When consensus cannot be achieved on a software upgrade, a fork occurs, effectively representing a divergence in software that can result in the formation of a new blockchain, and a new cryptocurrency to go with it.
Soft and Hard Forks
A soft fork is a software upgrade that is compatible with previous versions of a blockchain network’s software.
In other words, even if a miner doesn’t agree to install the upgrade, that miner’s software can still interact with the network.
However, if the majority of miners on a network install the upgrade, there will come a point at which transactions confirmed by miners operating on the old version of the software will be made stale.
A hard fork is a permanent divulgence from a blockchain. In other words, it occurs when a new set of consensus rules that are not compatible with the old rules is introduced onto a blockchain network.
All participants on a network are required to upgrade onto the new version of the software in order to continue confirmation transactions.
If there is enough support for the old version of a blockchain affected by a hard fork, then the two versions of the blockchains will operate independently of one another with two different cryptocurrencies.
Two famous examples of this are the split between Ethereum and Ethereum Classic, and Bitcoin and Bitcoin Cash.