Harry Rob.
Harry Rob.

Reputation: 45

Error after delete permanently a file from my git repository

I'm new with Git so I'm not sure if I'm working well.

I have delete a file from my git repository with this command:

git filter-branch --tree-filter 'rm -f application.log' HEAD

Everything went OK but when I'm trying to push my branch, I received this message:

$ git filter-branch --tree-filter 'rm -f application.log' HEAD
Rewrite a700a3de38f804b875a4dafabf01eaa90260e573 (1313/1313)
Ref 'refs/heads/master' was rewritten

$ git push origin master
To [email protected]:myuser/myrepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:myuser/myrepo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

How can I solve this problem?

Thanks!

Upvotes: 3

Views: 51

Answers (1)

user621486
user621486

Reputation: 446

The reason this error occurs is because you have changed history destructively. Use git push -f origin master to "force-push" your newly rewritten history.

Upvotes: 1

Related Questions