推后,删除的文件仍然存在于Git远程仓库中? [英] Deleted files still present in Git remote repo after push?
问题描述
我是Git的新手,试图让自己正确设置。我有一个远程repo和一个本地克隆,到目前为止只有一个(master)分支。
我在本地删除了一些文件,进行了这项修改,然后做了'git push origin master',这似乎可以成功运行。 'git status'现在没有在本地提交任何内容。
但是,当我查看远程repo时,文件仍然存在,'git status'显示它们全部如已添加但未提交。应推送我的更改没有从远程删除它们?我做错了什么?
问题是,你显然推到一个非裸仓库。推送将永远不会更新远程工作副本。
查看 Git只推送裸露的存储库?和 要使非裸露的远程存储库保持最新状态,请通过SSH连接到存储库所在的机器,并运行 要使远程存储库裸露,请通过SSH连接到本机,以便您可以直接访问它。假设存储库位于子文件夹 然后测试一切是否正常并且之后这 I'm new to Git, trying to get myself set up correctly. I have a remote repo and a local clone, with so far only the one (master) branch. I deleted some files in local, committed this change, then did 'git push origin master', which appeared to work successfully. 'git status' now shows nothing to commit in local. However, when I look in remote repo, the files are still there, and 'git status' shows them all as added but not committed. Should pushing my changes not have deleted them from remote? What am I doing wrong? The problem is that you apparently push to a non-bare repository. A push will never update a remote working copy. Have a look at Git push only for bare repositories? and http://gitready.com/advanced/2009/02/01/push-to-only-bare-repositories.html To bring the non-bare remote repository up to date, connect to the machine where the repo is located via SSH and run To make your remote repository bare, connect to the machine via SSH so you can access it directly. Assuming the repository is in a subfolder Then test if everything works and after this 这篇关于推后,删除的文件仍然存在于Git远程仓库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git reset --hard HEAD
和> git checkout -f
强制使工作副本保持最新状态(请注意,这将破坏您可能在该工作副本中完成的任何本地更改)。
repo
中,请运行以下命令:
mv repo repo_old
git clone --bare repo_old repo
rm -rf repo_old
摆脱旧的。git reset --hard HEAD
and git checkout -f
to forcefully bring the working copy up to date (note that this will destroy any local changes you might have done in that working copy).repo
run the following commands:mv repo repo_old
git clone --bare repo_old repo
rm -rf repo_old
to get rid of the old one.