Elon Musk has said hydrogen cars are silly and this is why he's right. First there are two basic types of hydrogen cars, one in which a car's internal combustion engine is fueled by hydrogen similar to a propane fueled vehicle and the other is a hydrogen fuel cell cars, which is an electric car that used hydrogen to create electricity. Using hydrogen as a fuel for an internal combustion still relies on the extreme inefficiency of any 4 stroke engine and without the energy dense properties of gasoline, meaning it would need much larger quantities of hydrogen to operate.
So let's first look how hydrogen is obtained. Pure hydrogen is very rare on earth, so it has extracted from water, which is one of earth's most stable molecules. There are two methods, one uses electrolysis and the other steam. The electrolysis method is very energy dense, meaning it takes almost as much electricity to extract the hydrogen as the amount of energy potential in the hydrogen itself (and of course most electricity is still produced using fossil fuels), this is why this process is not usually used commercially. The steam method is more efficient but again fossil fuels are used to create the necessary heat, so it's a renewable resource either. A hydrogen cell takes hydrogen and runs it through a hydrogen converter or cell, that converts back it into electricity and water. And while wind and solar electricity can be used to extract hydrogen from water, currently such renewable energy resources are overtaxed just trying to keep up with the current demands of the electrical grid and with standard power plants being shut down and no new ones being built, and with ever increasing demand for electricity in general, there not a whole lot of extra electricity available for making hydrogen for cars, let alone money to create the necessary infrastructure.
So hydrogen cars are silly because of the process of extracting hydrogen from water using electricity (electrolysis) and then using a hydrogen cell in the car to convert the hydrogen back into water (hydrolisys) and electricity is incredibly inefficient. No matter how sophisticated the hydrogen technology becomes, simply using the electricity that would be used to extract hydrogen from water to propel an electric car will always be more efficient. As an example it takes 50 kWh to extract 1 kg of hydrogen, this is enough to drive a hydrogen cell car about 100 km. OTOH a 50 kWh charge will likely propel a Tesla Model 3 about 230 km. The reason is due to the energy loss of extracting hydrogen from water and then converting the hydrogen back into water and electricity, the 50 kWh is reduced to less than 25 kWh of real world useable electricity. These figures are often debated because the overhead of hydrogen production by electrolysis and then reversed back into electricity is based entirely on the quality of the devices. While you will often see efficiency data much higher than this, they are usually referencing extraordinarily efficient laboratory devices used under very controlled conditions, while the devices commonly found in operation, for this process, such as in hydrogen cell vehicles are far less efficient.
It's also a misnomer that the explosive danger of hydrogen is even similar to that of gasoline. In it's natural state gasoline is a liquid and while highly flammable is not explosive unless it's vaporized with a very narrow margin of percentage of oxygen to be explosive. Hydrogen OTOH in it's natural state is an extremely explosive gas with a very wide margin of percentage of oxygen to be explosive. Further because of it's properties it is cost prohibited to store hydrogen as a liquid in small quantities, unlike propane or natural gas, so it would be transported in cars in it's most volatile state.
Now that is not to say electric cars are the answer either. As many have said electricity is only clean at the users end. Right now the US is on the verge of a dire electricity shortage that will probably bring electric car mandates to a screeching halt. Michael Shellenbuger (the scientist who oversaw the renewable resource infrastructure in California in the 1990s) explains that the electrical grid requires electricity as needed which is the fatal flaw of renewable wind and solar. The problem is there is no way to store the excess electricity from wind and solar, so at night or when there is little wind, the grid can be starved of electricity. Imagine then, when tens of millions of electric cars being plugged in at night to recharge their batteries for the morning commute at very time all the solar farms stop producing electricity (you can build as many solar farms as you want, but they still can't produce electricity at night). Wind and solar require large areas of land, usually in the desert, which is hundreds of miles from large population areas, this require s a large investment in infrastructure simply to get the electricity to users in far off cities that have the greatist demands for electricity. Building wind and solar farms are also having a devastating affect on the desert ecology, eg wind turbines are the now the leading cause of the deaths of predatory birds. Solar farms builders have been unable to prevent the whole sale deaths of endangered desert tortoises as they clear the desert floor for their solar array. Until the powers that be realistically plan and build the necessary infrastructure for a tripling of electricity demand, hybrid and gas powered cars will be around for a long time to come.
Now this does bring up the point, why not build hydrogen generating plants at solar farms? That way when solar farms are working at maximum efficiency on clear sunny days, they could divert the electricity not demanded by the electrical grid into hydrogen. Then when the power grid is in need of electricity, day or night, they could convert the hydrogen back into electricity, in affect creating a hydrogen battery to store electricity that is usually wasted when there is no demand for it by the power grid. Yes it's still inefficient in regards to lost electricity as a result of the conversation to hydrogen and back to electricity, but in this case the electricity was literally being thrown away, so any means of storing it is better than it being completely wasted. I have not seen this mentioned anywhere, but it would seem to me to be the answer to the inconsistent production of electricity that is the current fatal flaw of renewable energy, however it still doesn't address the destruction of the desert ecology, that pretty much seems to be the inevitable unintended consequence of renewable energy.