3

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 git@github.com:myuser/myrepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com: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!

Suraj Palwe
  • 2,080
  • 3
  • 26
  • 42
Harry Rob.
  • 45
  • 6
  • 1
    You have rewritten history, see http://stackoverflow.com/questions/10054611/how-to-push-new-rewritten-history-to-remote-repository. You can force-push with `git push -f`, but be careful! – sashoalm Jun 11 '15 at 08:20
  • It says you need to pull master branch first then push it because there are some changes on master branch which are not on your local machine. – Anuja Jun 11 '15 at 08:20

1 Answers1

1

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.

user621486
  • 446
  • 4
  • 6