-1

I want my local master branch to overwrite everything in the remote repository. Basically, it's like I checked out the remote repository, deleted some files, and now want to replace it again.

I'm getting an error message when trying to push back to the remote repository saying it "failed to push some refs" because my branch is behind. It suggests doing a pull. However, if I do a pull, it will re-merge the files I wanted to delete so I would be back to where I started. Then I tried doing a fetch without merging, and then pushing, but it still didn't work.

Vini.g.fer
  • 11,639
  • 16
  • 61
  • 90
apdm
  • 1,260
  • 1
  • 14
  • 33
  • Possible duplicate of [Force "git push" to overwrite remote files](http://stackoverflow.com/questions/10510462/force-git-push-to-overwrite-remote-files) – Uyghur Lives Matter Jun 30 '16 at 20:35

1 Answers1

3

You will need to force push. This will overwrite any changes that are on remote, but not local, so use with caution.

git push -f <remote> <branch>

Look here for more details

Community
  • 1
  • 1
Doug
  • 14,387
  • 17
  • 74
  • 104