Robustness of bitcoin I am wondering about the consequences of a potential 51% CPU attack on the bitcoin blockchain. Imagine that a state invests enough computational power to rewrite from scratch an entire blockchain, longer than the current bitcoin blockchain (maybe because the state wants to control money). In this forged blockain all blocks would be empty (no transactions), which means the state  owns all bitcoins as the result of mining.

In that case would it really be the end of bitcoin ? I have the impression that it would be easy to patch the nodes on the network to dismiss the forged blockchain, for example by banning the state's public key.

That would violate the intent of bitcoin that mathematics and cryptography replace trust in a third-party, but eventually bitcoin is used by people who need to trust it. They wouldn't want all their money destroyed by an attack.

Or are there 51% attacks harder to detect and to patch ? I am not asking about  short-chains attacks that would only rob a few merchants, rather about the global stability of bitcoin.
The start of @Saxtheowl's answer is correct, such an attack requires a huge amount of capital and investment to pull off, as the attacker will need to invest in a huge number of ASIC miners, and gain access to a huge amount of energy. Once the attacker is set up, they face the dilemma of just mining honestly and gaining a reward for doing so (block reward + fees), so there is a large opportunity cost in attacking that must be considered as well. 

You can take a look at the [majority-attack] tag to learn more.


  I have the impression that it would be easy to patch the nodes on the network to dismiss the forged blockchain, for example by banning the state's public key.


It is not possible to ban a miner from the network, because miners are not required to register with any authority/the network in order to submit blocks. A block does not contain a miner's public key, and in any case there is nothing stopping the miner from just creating a new key for every block. 

There is no way to just 'switch to another chain', there is no mechanism in the software to do so, without human intervention. Human intervention requires trust (that you're going to choose the correct new chain), and it provides no clear means of determining which new chain is the correct one. This is the function of the PoW, after all, if people could just agree on which chain is legit without PoW, then we wouldn't need PoW in the first place! To make matters worse, the attacker can just as easily switch to mining on the new chain.

The only 'solution' is for the rest of the network to contribute enough hashpower to bring the attacker below 51%. Perhaps a change to the PoW algorithm could happen, but that is a very messy fix which will cause a lot of collateral damage (loss of confidence, drop in price, etc). A PoW change could also be attacked, so it is unclear if this is a reasonable approach.