3

is it possible to delete/remove some unwanted files from remote and local repository?
I was a bit to fast and pushed 5 files to the remote repo. Now my colleague pushed his work and saw to late these unwanted files. So now there are 2 commits after my 'wrong' commit.

I tried to use

git rebase -i HEAD~3

and changed the first entry to "edit" and deleted that unwanted files. Next I used

git commit --amend
git rebase --continue

But GIT wont finalize it. It always said that I'm at the last commit and there is a rebase in progress. But I'm not able to continue to finish it.

2 Answers 2

6

You can easily remove unwanted files from local git repositories:
Just remove them with
git rm file
or
git rm -r directory (if you add the --cached-flag the file doesn't get removed from your filesystem). Then commit (or commit --amend) to remove the file from the last commit (it stays in in the history, though). See also here

If you want to remove it from a remote repo follow the same steps and push afterwards.

2
  • This doesn't remove it from the git history.
    – Gokul N K
    Commented Sep 22, 2016 at 13:27
  • I said so, I believe...
    – Fabio
    Commented Sep 23, 2016 at 8:46
-1
git rm file
git commit --amend
git push origin HEAD:refs/for/develop

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .