我是Git的新手,所以我不确定自己是否运作良好。
我已使用此命令从我的git存储库中删除了一个文件:
git filter-branch --tree-filter 'rm -f application.log' HEAD
一切都顺利但是当我试图推动我的分支时,我收到了这条消息:
$ 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.
我该如何解决这个问题?
谢谢!
答案 0 :(得分:1)
发生此错误的原因是您破坏性地更改了历史记录。使用git push -f origin master
“强制推送”您新重写的历史记录。