Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files not updating using 'git pull'

Tags:

git

git-pull

I am using Git to cooperate with other users, but today I cannot get the latest change on some files using "git pull", and I cannot see the changes in "git log".

What could be the issue?

like image 240
cao lei Avatar asked Dec 14 '13 10:12

cao lei


People also ask

Why my git pull is not working?

This might be happening because of some conflict files present in your repository . And you was still trying to check in files . So After that what happen , it will check in your local repository not in master repository . So u was not able to pull or check in anythings in master(head) repository .

Why git pull does not get the latest changes?

git pull Not Updating Files Due to Uncommitted Files in Your Local Repository. As a source code management system, Git does its best to prevent you from losing your files and data. For this reason, Git may refuse to merge your local files with files from your remote repository when performing the git pull command.

Does git pull update local files?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.


3 Answers

what worked for me is ,

  1. remove .git folder
  2. copy .git from other repo
  3. now git checkout

Before Removing , You can try

git fetch --all 
git reset --hard origin/master

You will need to replace master with the appropriate branch, which now defaults to main.

like image 94
ganesh Avatar answered Oct 11 '22 06:10

ganesh


What worked for me,

git reset --hard origin/master

It showed me that some file names were too long for git to pull them from my repo and hence the mismatch and incorrect builds.

So I ran following to fix and did a hard reset again.

git config --system core.longpaths true

Thankfully it worked.

like image 23
Dish Avatar answered Oct 11 '22 08:10

Dish


In my case the issue was me having an index.lock file in my .git folder. I removed that, and pull worked.

like image 9
Alwyn Schoeman Avatar answered Oct 11 '22 06:10

Alwyn Schoeman