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:
Edit 2:
(also done with add and commit)
It may be that:
files/folder you are trying to push match an entry in .gitignore
origin url is different from where you're looking. Perform git remote -v
to verify
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.
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.
Created a new branch 'dev':
git checkout -b dev
Pushed the new branch to GitHub to get an offsite backup before I messed around:
git push origin dev
Switched back to 'master' branch:
git checkout master
Replaced all code in 'master' with 'dev':
git reset --hard dev
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.
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.
Forced the local code to overwrite the remote code:
git push -f origin master
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With