Knowledge - Details
Date Added: 1/13/2022
By default, Visual Studio will not allow you to force push (git push -f) your local commit to the remote repo since it is a dangerous action that can cause data loss in the remote repo. To enable the ability despite the risk, in VS2022, go to Git > Settings > Git Global Settings, and enable "Enable push --force-with-lease". Now, when you click "Push" in VS, instead of just getting an error with a recommendation to Pull instead, the error messagebox will also include an option to Force Push. I suggest turning this setting back off when you're finished using it so you don't accidentally click it later.
Disclaimer: Everything on this website is written for my own use. I disclaim any guarantees that the procedures and advice listed here are accurate, safe, or beneficial for anyone else. If you attempt to follow any procedures or advice shared here, you do it at your own risk. Part of IT work is knowing how to recover from problems.