74

I have 3 repos. A bare repo which I use as a master repo, a dev repo in which I make and test changes, and prod repo from which scripts are executed in the prod environment.

After I have tested changes in the dev repo I push them to the bare repo and they are auto pulled down into the prod repo on a cronjob using a basic script (carrying out git pull command).

I followed through the above procedure for a change, but the altered file will not update in the prod repo.

  • The change is checked in and pushed in the dev repo
  • The pull has been done to the prod repo
  • The git logs for all repos are identical and all show the checkin for this change
  • git branch gives me "* master" for all repos
  • git status for all repos gives me: # On branch master nothing to commit, working directory clean
  • git pull gives me "Already up-to-date" for the dev & prod repos

Using git extensions for a graphical view, it appears each repo is up to date and at the head.

I've tried:

git checkout HEAD  
git pull origin master  
git reset --hard HEAD  
git reset --hard origin/master  
git reset origin/master  

Can anyone help here?

phuclv
  • 37,963
  • 15
  • 156
  • 475
bren
  • 843
  • 1
  • 7
  • 7

4 Answers4

205

Try this:

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

Explanation:

git fetch downloads the latest from remote without trying to merge or rebase anything.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Devarsh Desai
  • 5,984
  • 3
  • 19
  • 21
  • 3
    Hey, yeah that worked, Thanks!. I still don't get how nothing flagged as being out sync and logs suggested that the repos all matched, but it solved the problem anyhow! I'll read up more on fetch... – bren Aug 20 '14 at 21:15
  • 5
    Yea this happened to me as well, `git fetch` on it's own didn't pull my changes. But `git fetch --all` solved it. Weird. – Strobe_ Feb 06 '17 at 17:28
  • thank you, it worked for me! Then the `git pull` finally downloads the latest version. – enri Jun 25 '18 at 08:36
  • Awesome, worked for me. I deleted a local directory and `git pull` was saying I was up to date, but this refetched the deleted directory. Thanks! – James Hooper Jun 21 '21 at 11:28
2

For me my forked branch was not in sync with the master branch. So I went to bitbucket and synced and merged my forked branch and then tried to take the pull. Then it worked fine.

Kartik
  • 83
  • 9
  • 2
    I was using forked repository for the first time and didn't realize this scenario. Synced my forked repository with the upstream (original) repository and then could get changes to my local. _Reference: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork_ – user0904 Jun 11 '20 at 15:53
1

If you're only interested in getting a specific local branch up to date:

git fetch origin
git reset --hard origin/[name of your branch]
daCoda
  • 3,583
  • 5
  • 33
  • 38
0

Our upstream repo had wrong master tag so was forced to delete it in our fork repo:

git reset --hard upstream/master 
git tag -d master
git push origin master
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101