我在公司中使用了git企业。当我' git push '时,它告诉我以下错误。
$ git push
Counting objects: 289, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (264/264), done.
Writing objects: 100% (289/289), 9.95 MiB | 207.00 KiB/s, done.
Total 289 (delta 37), reused 0 (delta 0)
remote: Resolving deltas: 100% (37/37), completed with 4 local objects.
remote: hooks/xxxx.sh: failed with exit status 1
remote: refs/heads/master 347a6011604730df57a348f8aa166b747d9684fe 4f6d30e187b4d20ea5ba56bd9babcdf3a3b3021b
remote: We have restricted committing abc.zip filetype.
remote: ********RESTRICTED********
remote: abc.zip
remote: **************************
To https://gitprod.xxx
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://gitprod.xxx
如何删除zip文件并再次按下,我尝试了几种方式,但找不到正确的方法。谢谢。
您意外地上演了该修复的文件类型,因此您需要删除它。
使用:
git reset -- <filePath>
或
git rm --cached <filePath>
只需替换&lt;filepath>带有zip文件的实际路径。
然后,尝试提交并再次推动。(但不要将该文件包括在您的提交中。)
由于您的上一个(未使用)提交包含不需要的文件,我们需要撤消它,然后在没有它的情况下再次提交:
# undo last commit (but keep changes in working tree)
git reset --soft HEAD^
# unstage your .zip file
git reset HEAD path/to/abc.zip
# commit and push again
git commit -m "Message here"
git push
(自上次推动被拒绝以来,无需使用--force
推动。)
如果将此文件添加到您的最后一个提交中,则需要使用git commit --amend
。
修改之前,只需用git rm --cached abc.zip
删除文件。