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...

@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