从GIT中删除目录后如何提交 [英] How to commit after removing a directory from GIT
问题描述
几篇文章讨论从GIT中删除文件或目录 - 但他们没有解释如何将这些更改压入主存储库。
Several posts talk about removing a file or directory from GIT - but they don't go as far as explaining how to PUSH those changes into the main repository.
例如,这可以很好地移除目录,但当我尝试把这个改变推到主Git仓库中,我被拒绝了:
For example, this works just fine to remove the directory but when I try to PUSH this change to the main Git repo, I am denied:
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to '/repo/project.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
最后一步是将其推到主repo并实际移除该目录? p>
What is the last step to actually push this to the main repo and actually remove that directory?
推荐答案
当您删除某些内容时,您会重写历史记录。因此,上游存储库拒绝您的更改,因为这会导致历史记录丢失。在这种情况下,您需要使用
When you remove something so aggressively, you rewrite history. Therefore, the upstream repository is rejecting your change because it would result in a loss of history. In this case, you will need to use
git push --force
这篇关于从GIT中删除目录后如何提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!