Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mingderwang/94205de855af7c60cafa88564ea6abd7 to your computer and use it in GitHub Desktop.

Select an option

Save mingderwang/94205de855af7c60cafa88564ea6abd7 to your computer and use it in GitHub Desktop.
hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull origin master //run this first, then
$ git push origin master
@sara-pourabbas
Copy link
Copy Markdown

Bro didn't work for me this solutions.Dont give trash info.You failed bro.So my friend Onur solved this problem.Don't do this againn maan.İf you don't know, don't sniff again.

try git push -f origin master

This works for me , Thank you.

@toppylawz
Copy link
Copy Markdown

Bro didn't work for me this solutions.Dont give trash info.You failed bro.So my friend Onur solved this problem.Don't do this againn maan.İf you don't know, don't sniff again.

try git push -f origin master

works amazingly.

@irepairny
Copy link
Copy Markdown

graet! git push -f main worked for me

@Md-Moniruzzaman
Copy link
Copy Markdown

Thanks this is really helpful for me

@Guta19
Copy link
Copy Markdown

Guta19 commented Mar 28, 2022

Thanks! git push -f origin master worked for me

@adityaharist
Copy link
Copy Markdown

git push -f origin master
Command above, it's so helpfully for anyone who in terminal says:

! [rejected] master -> master (fetch first)
error: failed to push some refs to '[your repo]'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

@saeidabdi
Copy link
Copy Markdown

Thanks! It worked
@Xenia-Io

@apaarsadhh
Copy link
Copy Markdown

I even had the same issue and i couldn't fix it with git pull but i tried this and it worked:
git push -f origin master
So try all previous steps but for git push use argument -f

It worked for me

You 're welcome !!!! But just be careful because with what i proposed "git push -f origin master" you update the whole repo and changes will be overridden from now on. So we should not do "git push -f origin master" every time - especially if you have contributors in your repo - you may need to do git reset then !!!

Thanks a lot 👍👍👍

@peternguyen173
Copy link
Copy Markdown

git push -f origin master

thank you it also worked for me too!

@Shubhamgupta0596
Copy link
Copy Markdown

thanks works for me as well

@asgharali101
Copy link
Copy Markdown

try git push -f origin master this worked..Thank u very much Xenia

it work for me ,,i am worried about it .thank you gentleman

@itihask56
Copy link
Copy Markdown

Yeah, it worked !!
Actually, my branch is main, so I had just changed the command: git push origin -f master, to command: git push origin -f main

@dipakshendge
Copy link
Copy Markdown

I even had the same issue and i couldn't fix it with git pull but i tried this and it worked:
git push -f origin master
So try all previous steps but for git push use argument -f

This worked great for me, thank you @Xenia-Io

thanks it's working...

@vinaykasam13
Copy link
Copy Markdown

Thank you so much, worked for me as well

@RadriaansNES
Copy link
Copy Markdown

Nothing was working from me. Copied previously local git files from folder into new folder and easily overwrote it.

@Shubham651-creator
Copy link
Copy Markdown

It's work very fine, thanks!

@Rakshitharashgithub
Copy link
Copy Markdown

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

please check the above error I'm getting while push please check and let me know the solution

@Shubham651-creator
Copy link
Copy Markdown

I am just run only two commands.

  1. git pull origin
  2. git push origin

@GurwinderSethi
Copy link
Copy Markdown

Thank you so much for such a magnificent work

@ejazulhaq91
Copy link
Copy Markdown

great! git push -f main worked for me

@ashutoshlivnest
Copy link
Copy Markdown

git pull origin main
git add .
git commit -m "Merge remote changes"
git push origin main

@RonaldBeckstead
Copy link
Copy Markdown

I am having a problem, can I ask it here or start a new thread?

@thibapso
Copy link
Copy Markdown

thibapso commented Feb 6, 2024

Bro didn't work for me this solutions.Dont give trash info.You failed bro.So my friend Onur solved this problem.Don't do this againn maan.İf you don't know, don't sniff again.

try git push -f origin master

This worked for me. Thank you so much!

@LevarGoldun
Copy link
Copy Markdown

Thanks, it all worked. Most likely my error was due to the fact that I manually uploaded the file to github, but locally it wasn't showing up.

@spxctr00m
Copy link
Copy Markdown

I used git push -f origin main and it worked for me.

@M1k3ll
Copy link
Copy Markdown

M1k3ll commented May 1, 2024

use "--force"
"git push -u origin main --force

@lib4u
Copy link
Copy Markdown

lib4u commented Aug 6, 2024

git push -f origin just remove all commits, better not use this if you not sure

@AmitBisht01
Copy link
Copy Markdown

Great! it worked, Thanks🫡

@luwukien
Copy link
Copy Markdown

Bro didn't work for me this solutions.Dont give trash info.You failed bro.So my friend Onur solved this problem.Don't do this againn maan.İf you don't know, don't sniff again.

try git push -f origin master

haha =))) thank you very much

@allanchen2019
Copy link
Copy Markdown

Really helpful for me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment