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,260 points
1,905 views

1 answer to this question.

0 votes

Hi@akhtar,

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,460 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,230 points
1,619 views
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,620 points
18,903 views
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
784 views
+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
4,059 views
+2 votes
1 answer
0 votes
1 answer

How to ignore an error on 'git pull' about my local changes would be overwritten by merge?

Hi Team, If you want to remove all ...READ MORE

answered Jan 5, 2021 in Git & GitHub by MD
• 95,460 points
3,102 views
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,460 points
2,405 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP