What is forking in blockchain?
A fork is said to have happened when there is a conflict among the nodes regarding the validity of the blockchain, that is, more than one blockchain happens to be in the network. There are three kinds of fork: regular, soft, and hard.
A regular fork is said to be happening when there are two or more blocks at the same height. It is a temporary conflict and is resolved automatically. This is resolved by nodes by selecting the most accurate blockchain. For example, in proof-of-work, if two miners mine a block at the same time then it creates a regular fork. And, this is resolved by selecting the blockchain with the highest difficulty as the most accurate one.
A soft fork, by contrast, is any change to the blockchain protocol that's backward- compatible. Say, instead of 2 MB blocks, a new rule might only allow 1 MB blocks. Non-upgraded nodes will still see the new transactions as valid (1 MB is less than 2 MB in this example). However, if non-upgraded nodes continue to create blocks, the blocks they create will be rejected by the upgraded nodes. So, if the minority of a nodes in the network are upgraded then the chain they will form will become less accurate and overridden by the blockchain created by the non-upgraded nodes. Soft forks are resolved when the majority of the nodes in the network upgrade their node software.
A hard is a software upgrade that introduces a new rule to the network that isn't with the older software. You can think of a hard fork as an expansion of the rules. For example, a new rule that allows the block size to be 2 MB instead of 1 MB would require a hard fork. Nodes that continue running the old version of the software will see new transactions as invalid. So, the fork can only be resolved when all the nodes in the network upgrade their node software. Until then, there will be two different blockchains in the network.