How to force git pull to overwrite local files

+1 vote

Hi Guys,

I have some files in the local Git as well as Github. One of my team members updated something on Github. Now I want to pull all the files to the local server. But how can I overwrite the previous data with new data?

Sep 4, 2020 in Git & GitHub by akhtar
• 38,210 points

1 answer to this question.

0 votes


First, you need to download the latest from remote without trying to merge or rebase anything using the below-given command.

$ git fetch --all

Then use the git reset command to reset the master branch to what you just fetched. But in this command, you need to use --hard option to change all the files in your working tree to match the files in origin/master.

$ git reset --hard origin/master
answered Sep 4, 2020 by MD
• 95,320 points

Related Questions In Git & GitHub

0 votes
2 answers

How to view the nested workflow of a local git repository?

The closest way to view branches in ...READ MORE

answered Aug 2, 2019 in Git & GitHub by Sirajul
• 59,090 points
0 votes
1 answer

Error: git pull fails “unable to resolve reference” “unable to update local ref”

This happens when there are unnecessary files ...READ MORE

answered Jul 26, 2018 in Git & GitHub by Sophie may
• 10,550 points
0 votes
1 answer

How to get the files from the local desktop to the local repository?

Hey @Ali, Follow these steps to transfer ...READ MORE

answered Dec 17, 2018 in Git & GitHub by Arohi
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to configure git send-email in local system?

Hi@akhtar, To use git send-email service you have ...READ MORE

answered May 4, 2020 in Git & GitHub by MD
• 95,320 points