git 如何删除远程存储库中的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8539338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to delete files in the remote repository?
提问by dvliman
I am not sure what is the exact term for this problem. Basically, I need to remove some files & directory on my remote repository
我不确定这个问题的确切术语是什么。基本上,我需要删除远程存储库中的一些文件和目录
I have a local git repo & remote repo in github
我在 github 中有一个本地 git 仓库和远程仓库
- Had been working myself.
- A friend made a pull request.
- I merged his request (via github interface)
- I pulled the changes.
- I tested the code and decided not to take his changes (shouldn't have merged at the first place)
- I reverted back to a previous commit
- Made some changes
- Push to the server.
- 自己一直在工作。
- 一位朋友提出了拉取请求。
- 我合并了他的请求(通过github接口)
- 我拉动了变化。
- 我测试了代码并决定不接受他的更改(一开始就不应该合并)
- 我恢复到以前的提交
- 做了一些改动
- 推送到服务器。
This is how my local repository looks like at the moment:
这是我的本地存储库目前的样子:
* 7e143b1 (HEAD)
|\
| * 18cea0f (origin/master, origin/HEAD, master)
| |\
| | * fc19ccf
* | | 6f3c58a
|/ /
* | 8d82486
|/
| * d3ce65f (pre-install-activeadmin)
|/
* 7d0566c
* d1c77ab
* 75ba704
* 30dc67c (heroku/master)
* f89b1f6
* ea5e2db
* 08931d6
* 9773a6f
* b636aba
* cb6f8d4
I can change my local repo to 7d0566c
. I am not sure where the head on my remote repo is pointing to.
我可以将我的本地存储库更改为7d0566c
. 我不确定我的远程仓库的头部指向哪里。
How do I remove those files that are on remote repo but are not on my local repo?
如何删除远程存储库中但不在本地存储库中的那些文件?
Obviously, I do not see any of his files in my local repo because I did a reset of my HEAD to a previous commit. However, the remote repo still shows his files. When I commit, it commits just fine.
显然,我在本地存储库中没有看到他的任何文件,因为我将 HEAD 重置为之前的提交。但是,远程仓库仍然显示他的文件。当我提交时,它提交得很好。
Is my workflow wrong? I should have just tested the patch at the first place. Any suggestion? I am new to version control. Thank you
我的工作流程错了吗?我应该首先测试补丁。有什么建议吗?我是版本控制的新手。谢谢
回答by Ry-
Pull the changes from the server, then do a git rm
on your local repo, commit the changes, and push to the server. The files will be deleted.
从服务器拉取更改,然后git rm
在本地存储库上执行更改,提交更改并推送到服务器。文件将被删除。
回答by htanata
I'm assuming 18cea0f
is where your pull request merge happened. In order to revert that merge, you can do:
我假设18cea0f
是您的拉取请求合并发生的地方。为了恢复该合并,您可以执行以下操作:
git revert -m 1 18cea0f
You can read more here: http://progit.org/2010/03/02/undoing-merges.html
您可以在此处阅读更多信息:http: //progit.org/2010/03/02/undoing-merges.html