Delete the file that I should not have attached to Git

So what I did badly.

Somewhere during a bunch of changes, I realized that an unintended file made it into a commit or two. Since I did not understand this until a later time, the commits that included this file were now transferred to the remote computer. I need and need commits, I just want to delete this file from them.

I need to make, of course, access to every corner of my tree (local and remote) and destroy this file. I tried several things using filter-branch and filter-tree , but when I try to click, the changes are rejected.

What are my options? What am I doing wrong?

Thanks.

UPDATE

At maximum request, a message appears here that I receive when I try to click:

 $ git push origin develop To git@codaset.com :robwilkerson/cakephp-polyclip-plugin.git ! [rejected] develop -> develop (non-fast-forward) error: failed to push some refs to ' git@codaset.com :robwilkerson/cakephp-polyclip-plugin.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. 
+4
source share
3 answers

Have you added -f (force) to pressing git? Without this flag, you cannot overwrite "old" commits.

 -f, --force Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care. 

This can become messy if others are already pulled from this repository.

+2
source

GitHub has a nice guide that can help you.

+10
source

You could simply implement the fix as a β€œnew fix,” for example. delete the file and send the patch to the repository.

Then it should extend to each branch when they are synchronized with your version where you made changes.

0
source

All Articles