A fork represents a change in the rules or protocol of a blockchain, resulting in a split into two separate chains.
In a blockchain, forks are changes to the network's protocol that result in diverging paths. There are two main types of forks: soft forks and hard forks.
A soft fork is a change to the blockchain's protocol that is backward compatible. What this means is that even if some nodes in the network do not upgrade to the new rules, they can still validate transactions and blocks according to the old rules.
Soft forks tighten or add new rules to the protocol, but do not invalidate any of the existing rules. For example, if the new rules say that block size should be 1MB instead of the previous 2MB, the blocks created under the new rules (1MB) would still be accepted by nodes that didn't upgrade, as they fall within the previous rule of being under 2MB. However, blocks created by non-upgraded nodes might get rejected if they exceed the new block size limit.
This type of fork only requires the majority of the miners to upgrade in order to enforce the new rules, as their combined computational power will be able to outpace any remaining miners who did not upgrade, gradually orphaning blocks produced under the old rules.
A hard fork, on the other hand, is a non-backward compatible change to the blockchain's protocol. This means that all nodes must upgrade to the new rules to validate and verify new transactions and blocks. If some nodes do not upgrade, they will follow a different protocol and may start a new blockchain path based on the old rules.
Hard forks can be planned or contentious. Planned hard forks are generally accepted by the community and lead to an upgrade of the system without creating a new currency. An example of this is the Ethereum's Byzantium hard fork, which was an upgrade to the Ethereum network agreed upon by the community.
Contentious hard forks occur when there is disagreement within the community, and this can result in a split of the blockchain into two separate chains, each running its own version of the protocol and having its own currency. An example of a contentious hard fork is the creation of Bitcoin Cash from Bitcoin in 2017, where there was disagreement over block sizes.
In both types of forks, the decisions to make changes are generally guided by a consensus mechanism where participants in the network agree on the changes to be made. The difference lies in the compatibility of the new rules with the old ones.
Examples of a hard fork include Bitcoin Cash forking from Bitcoin and Ethereum Classic forking from Ethereum. In both instances, disagreements within the community about future direction and growth of the blockchain led to a split.