Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push not updating files although changes have been made

Tags:

git

git-push

I know it has been asked before, but the other threads did not solve my problem.

1: I am working with a remote git rep and although i made changes on my local files and used git push origin master --force, it did not update all the files in the remote rep.

my workflow:

cd projectfolder

git add *

git commit -m "update v1.0"

git push origin master

also

git push origin master --force

Response is, that rep is already up-to-date

2: I also set up a test rep, and there is the issue that I should fetch first, since there are changes in the remote rep, is there a way to still force push in this case?

Thanks in advance!

Edit 1: enter image description here

Edit 2: (also done with add and commit) enter image description here

like image 302
dzitrus Avatar asked Sep 12 '25 10:09

dzitrus


2 Answers

It may be that:

  1. files/folder you are trying to push match an entry in .gitignore

  2. origin url is different from where you're looking. Perform git remote -v to verify

like image 198
letthefireflieslive Avatar answered Sep 15 '25 01:09

letthefireflieslive


I had this exact problem, and it turns out that GitHub was rejecting the updates because of conflicts but no error was displayed: my local terminal stated that the updates had been successful. It was only a couple of weeks later that I looked at the GitHub page and realised it was two weeks out of date.

Here's how I resolved it.

  1. I copied the entire local repository folder into another folder as a backup, just in case everything went pear-shaped. This turned out to be a Really Good Thing because files in .gitignore were removed during the fix.

  2. Created a new branch 'dev':

    git checkout -b dev

  3. Pushed the new branch to GitHub to get an offsite backup before I messed around:

    git push origin dev

  4. Switched back to 'master' branch:

    git checkout master

Replaced all code in 'master' with 'dev':

git reset --hard dev
  1. Copied my settings file back into the folder from my backup folder - it is in .gitignore so that my private settings aren't copied into the repository, and it was deleted by step 4.

  2. Tried the git push to origin which previously appeared to work but didn't:

    git push origin master

NOW I got an error saying that the updates were rejected. This made sense because I did a major rewrite two weeks ago but had not realised that GitHub silently rejected the new code.

  1. Forced the local code to overwrite the remote code:

    git push -f origin master

  2. Refreshed my GitHub page and saw the new code. Phew!

What I've learned is that when I make a major change, I need to check the GitHub repo to make sure everything is up to date.

like image 28
Little Brain Avatar answered Sep 15 '25 01:09

Little Brain