Git:远程仓库中的头提交是废话 - 我应该如何去替换它? [英] Git : Head commit in remote repository is crap - how exactly should I go about replacing it?
问题描述
好吧 - 我有一个人(在学校项目中 - 不要恐慌)提交一个完整的eclipse工作空间,完整的.class文件和.settings /目录。 是克隆回购并制作.gitignore文件并发行:
$ git reset --soft HEAD ^
$ ... unstaged所有文件并添加.gitignore和它过滤的所有文件...
然后我试过:
$ git commit -c d1cf2d8173234b444c601d5e294a5cf6d790fa2c
SHA是联机提交的SHA。它不会让我推:
推送到 https://USERNAME@git.assembla.com/PROJECT.git 至
https://USERNAME@git.assembla.com/PROJECT.git ! [已拒绝]
master - > master(非快进)错误:无法将某些参考推送到
'https://USERNAME@git.assembla.com/PROJECT.git'为了防止
丢失历史记录,拒绝非快进更新在再次推送之前合并
远程更改(例如'git pull')。有关详细信息,请参阅'git push --help'中有关'快速转发'的'注意
'。
我的问题是 我应该怎么做? 在这种情况下。不要警告我不应该这样做 - 在这种情况下,编辑历史记录(我想回收在线回购空间)是非常好的,建议和必要的。另外 - 我真的不担心如何强制推送 - 我希望 用另一个 替换远程HEAD提交的更简单/更清晰的方式。
这一切都始于一个克隆...
除了必须获得远程回购管理员可让您倒退主分支,请参阅 http://help.github.com / remove-sensitive-data / ,特别是清理和回收空间部分。
重新开始一个新的远程和有远程管理员完全删除旧的,像你的情况。 : - )
Alright - so I had a guy (in a school project - don't panic) commit a full eclipse workspace complete with .class files and .settings/ directories. What I did was to clone the repo and make a .gitignore file and issue :
$ git reset --soft HEAD^
$ ... unstaged all files and added .gitignore and all files that it filtered in ...
Then I tried :
$ git commit -c d1cf2d8173234b444c601d5e294a5cf6d790fa2c
Where the SHA is the SHA of the online commit. It won't let me push :
Pushing to https://USERNAME@git.assembla.com/PROJECT.git To https://USERNAME@git.assembla.com/PROJECT.git ! [rejected]
master -> master (non-fast-forward) error: failed to push some refs to 'https://USERNAME@git.assembla.com/PROJECT.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
My question is what should I have done instead ?
So how exactly should I go about deleting a commit in this scenario. Do not warn me that it shouldn't be done - in this case it is very well acceptable, recommended and necessary to edit the history (I want to reclaim the space in the online repo). Also - I am not really worried how to force the push - I want the easier/cleaner way of replacing the remote HEAD commit with another.
It all starts with a clone...
Aside from having to get the remote repo admins to allow you to rewind the "master" branch, see http://help.github.com/remove-sensitive-data/ and in particular, the "cleanup and reclaiming space" section.
It's often simplest to start over with a new remote and have the remote-admins delete the old one entirely, in cases like yours. :-)
这篇关于Git:远程仓库中的头提交是废话 - 我应该如何去替换它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!