0

Here's my situation:

I wanted to do a once-and-done push to a git repo. So, I did the add, commit, and push as usual. Except, I forgot that I had other files in previous commits that also got pushed. So, now there are unnecessary files contaminating the repo (remotely) that I pushed to. I want to remove those unnecessary files.

I don't want to pull from the remote repo because I'm not interested in getting any of those files. So, I effectively want to do something like a git filter-branch but only on the remote repo.

How do I remove files from the remote repo without pulling/pushing again locally?

makansij
  • 9,303
  • 37
  • 105
  • 183

1 Answers1

0

You could revert the commit (git revert [commit sha]) and do it again properly removing the files you don't want and keeping the files you do, and then package that up in a new commit.

mohammedkhan
  • 953
  • 6
  • 14
  • but won't the files still be present in the history of the remote repository? – makansij Jan 20 '16 at 17:54
  • A history of deleted files always remains in git, that's not really a bad thing. If you're really keen on not having it in the history at all you would probably look to reset the branch before your change, remove the files and then do a forced push. But forced pushes should be used as a last resort measure and if they can be avoided then they should be at all cost: http://willi.am/blog/2014/08/12/the-dark-side-of-the-force-push/ – mohammedkhan Jan 21 '16 at 09:58