Skip to content

Instantly share code, notes, and snippets.

@ddeveloperr
Last active September 6, 2023 15:52
Show Gist options
  • Save ddeveloperr/97e7866b3da8042f1ea6324d337a1836 to your computer and use it in GitHub Desktop.
Save ddeveloperr/97e7866b3da8042f1ea6324d337a1836 to your computer and use it in GitHub Desktop.
How to force “git push” to overwrite remote repo files WITH LOCAL files

You want to push your local files to remote files

git push -f <remote> <branch>
git push -f origin master

Local version has priority over the remote one!

more...

@Ndinyo
Copy link

Ndinyo commented Jun 8, 2021

Thank you, really needed this.

@ddeveloperr
Copy link
Author

I really appreciate it. :) Stay connected here on GH .... I've just back to your profile and follow you and will learning something for sure
@Ndinyo @cgsdesign @BlackGlassSkin @aheze @lifeeric @ericksa @bigOconstant @SwedhaBalasubramanian @arhoy @realJema

"Instead of better glasses, your network gives you better eyes." -- Ronald Burt

Regards,
Kemal

@gasiferox
Copy link

Easy and smooth... Thanks

@Er-shams
Copy link

Er-shams commented Sep 2, 2022

thanks

@englit2008
Copy link

Thank you. It's works for me also. Good Job!

@lifeeric
Copy link

lifeeric commented Sep 15, 2022

[Hack] easy way is to change url directly from the source code,
open .git/config file in your favorite editor or nano , vim.

$ nano .git/config

and change the url = git@github.com:lifeeric/uploadToS3.git your repo url:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = git@github.com:lifeeric/uploadToS3.git     # here paste your url
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main
[pull]
        rebase = false

Hope you like it. thank you!

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