This is a little post on how you can override your local repository with files from git repository.
Why would you want to do that?
So, recently I was working on a WordPress plugin. I was using git for version control. I committed my changes to git.
After that I made some changes in the code which messed up few things. So I needed to go back to my previous committed flight.
If you face any similar issue, you will need to do this.
Overriding Local Repository With Git Repository
It's really very easy.
Open your local repository in your terminal/command prompt.
First, write this command.
git fetch --all
What this does is it fetches all the files from git repository but it doesn't do anything with them.
Then we write this command.
git reset --hard origin/master
This command resets the master branch with files we fetched with previous command. –hard option changes files in local repository to match with the files from git repository.
It's really as simple as that.