To get pet hair out of your carpet you can use a squeegee to rake the pet out of the carpet.
You can also buy a carpet rake online or in stores to rake the dog or other pet hair out of the carpet and then vacuum it up.
Chewy.com also sells a pet hair removal tool that can be used on carpet but either the squeegee or the carpet rake will work best to get the pet hair out of the carpet or use a vacuum attachment made for removing pet hair from the carpet.