We have all been there - you’re ready to transfer your work from your local repository to a remote repo, only to realize that the trusted git push command is not doing the job.
You may have heard about the --force flag command before, and maybe that has even saved your day in the past. But do you understand how “Force Push” works in the background? Do you know when to avoid it?
Here’s a simple scenario: you are working on the same branch as Joe. You both pulled the latest version from the remote repository in the morning and started working. So far, so good.
Joe has finished his task and pushed his work to the remote repo. Joe is on his way to the gym and you carry on with your assignment. You conclude your work, and now just need to run git push to end your day.
Unlike other version control systems, Git does not allow any conflicts on the remote repository. This is a good thing because it reassures you that the repo is in a healthy state at all times.