When the solar wind comes to the earth it meets the Earth's magnetic field. Most of the tiny particles in the solar wind are pushed around the earth because of this magnetic field. They begin their journey around in a curve called the "Bow Shock". Just like water makes a curved wave in front of a boat, the solar wind makes a curve in front of the Earth.
After passing through a shock wave at the bow shock, the wind flows around the magnetosphere and stretches it into a long tail. However, some solar wind particles some how come in through the magnetic barrier and are trapped inside. Solar wind particles also rush through funnel-like openings (cusps) at the North and South Poles, releasing loads of energy when they hit the upper atmosphere. The Northern and Southern Lights (auroras) are the evidence we can see of this energy transfer from the Sun to the Earth.
The particles then follow a path that goes around the earth in a sort of cover or sheath. This curve is called the "magnetosheath". These particles mix with other particles that come up from the earth's ionosphere to fill the magnetosphere.
Many of the tiny pieces of matter in the earth's magnetosphere don't come from the sun's solar wind. They come from the earth. Our planet can lift air particles into space and these particles will become charged by the time they get there.
A planetary magnetosphere is different from an ordinary dipole. The force of the solar wind, coming from the sun stretches the dipole and creates a nose region in the front of the magnetosphere (facing the sun), and a tail region in the back called a magnetotail.
If it weren't for the solar wind, a planet's magnetic field would extend forever.