GitHub上面有些文件想删掉,应该在本地怎么操作呢?

Liutos

来自: Liutos(fun: https://liutos.github.io)
2012-09-21 10:59:48

×
加入小组后即可参加投票
  • 脚气又犯了

    脚气又犯了 2012-09-21 11:07:28

    把本地的git clone 一份,或者建个分支,干掉之后再拿回来。。。。。。。。。

  • Liutos

    Liutos (fun: https://liutos.github.io) 楼主 2012-09-21 11:50:17

    把本地的git clone 一份,或者建个分支,干掉之后再拿回来。。。。。。。。。 把本地的git clone 一份,或者建个分支,干掉之后再拿回来。。。。。。。。。 脚气又犯了

    感觉好麻烦,还要学习怎么建分支了(〒▽〒)……

  • 题叶

    题叶 (jiyinyiyong) 2012-09-21 12:40:41

    分支是常用功能,, 必须学会的 另外学一下 .gitignore 文件的用法, 这个符合题目里的意思. 另外极端的用 git --filter-branch 这个参数我也就试过一次, 比较复杂, 总之看看吧

  • wu yuntao

    wu yuntao (当你注视坑时,坑也在注视你) 2012-09-22 11:20:07

    git rm --cached

  • Liutos

    Liutos (fun: https://liutos.github.io) 楼主 2012-09-22 15:33:12

    分支是常用功能,, 必须学会的 另外学一下 .gitignore 文件的用法, 这个符合题目里的意思. 另外 分支是常用功能,, 必须学会的 另外学一下 .gitignore 文件的用法, 这个符合题目里的意思. 另外极端的用 git --filter-branch 这个参数我也就试过一次, 比较复杂, 总之看看吧 ... 题叶

    .gitignore我知道,不过同步过一次的文件就没用了,毕竟已经在GitHub上了

  • 题叶

    题叶 (jiyinyiyong) 2012-09-22 16:13:40

    .gitignore我知道,不过同步过一次的文件就没用了,毕竟已经在GitHub上了 .gitignore我知道,不过同步过一次的文件就没用了,毕竟已经在GitHub上了 Liutos

    我的想法是先 mv 掉文件, 然后 push, 再文件 mv 回来前设置 .gitignore 如果要彻底, 只能先 --filter-branch 了

  • lvjian700

    lvjian700 (呐~做人呢,最要紧的就是开心.) 2012-09-27 16:48:43

    把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然后在 .gitignore 添加过滤, 或者不在同步 gtihubh

  • 挨了锤的牛

    挨了锤的牛 (难得糊涂) 2012-09-27 17:22:53

    把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然 把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然后在 .gitignore 添加过滤, 或者不在同步 gtihubh ... lvjian700

    这个正解~ 话说俺新手,望多多交流https://github.com/kelvin-fly

  • kelvin

    kelvin (灯红酒绿,过路小鬼。) 2012-10-14 16:07:58

    这个正解~ 话说俺新手,望多多交流https://github.com/kelvin-fly 这个正解~ 话说俺新手,望多多交流https://github.com/kelvin-fly 挨了锤的牛

    好像不用这么复杂吧。。 git push <remote> :master 这样貌似就会删除远端的master分支

  • Billy

    Billy 2012-10-20 00:54:52

    新手看完《pro git》,基本的操作就都知道了。

  • [已注销]

    [已注销] 2012-11-05 21:36:18

    [内容不可见]

  • [已注销]

    [已注销] 2012-11-05 22:04:54

    [内容不可见]

  • justashotaway

    justashotaway 2012-11-10 17:36:10

    四楼正解 git rm --cached filename git commit -m "hehe" git push origin branch 刚学了pro git,现学现卖,亲测有效。。 --cached 的指令 都是和staging area或者叫index有关的,就是git add了但还没有commit出去的状态。 git rm --cached filename 把文件从staging area中删了,再commit,push,就把github里面那份也删了。

  • fengxiaolong

    fengxiaolong 2013-02-02 19:46:43

    把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然 把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然后在 .gitignore 添加过滤, 或者不在同步 gtihubh ... lvjian700

    你这样搞很麻烦的呀。

  • 有趣的技术
  • Y君

    Y君 2013-03-20 00:50:20

    把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然 把文件copy出去. 然后git rm git add git commit git push 然后再把文件 copy 回来 然后在 .gitignore 添加过滤, 或者不在同步 gtihubh ... lvjian700

    貌似是正解

  • 0xFAN™

    0xFAN™ (我们都是游得最快的蝌蚪) 2013-03-20 03:38:10

    删除文件重新添加没用,服务器会保留所有历史,而且可以浏览,要么建立个新repo,历史都丢掉,要么用git filter-branch 然后git push -f,这样能保留记录,但所有commit都会被改写

  • Liutos

    Liutos (fun: https://liutos.github.io) 楼主 2013-03-20 10:46:30

    删除文件重新添加没用,服务器会保留所有历史,而且可以浏览,要么建立个新repo,历史都丢掉,要 删除文件重新添加没用,服务器会保留所有历史,而且可以浏览,要么建立个新repo,历史都丢掉,要么用git filter-branch 然后git push -f,这样能保留记录,但所有commit都会被改写 ... 0xFAN™

    新建repo倒不错,不过可能得先把原来那个干掉

  • 0xFAN™

    0xFAN™ (我们都是游得最快的蝌蚪) 2013-03-20 11:16:09

    关于删除所有历史记录里的某些文件 http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository

  • esus4

    esus4 2013-04-21 13:42:07

    git rm --cached git rm --cached wu yuntao

    that‘s it

  • cloudaice

    cloudaice (个人博客www.cloudaice.com) 2013-06-02 04:45:20

    上面的一些解法只是保持以后不会跟踪了,要想彻底删除的方法如下: git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch path/to/your/file' HEAD git push origin master --force rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --prune=now git gc --aggressive --prune=now

  • 努力

    努力 2013-11-08 21:07:40

    需要GitHub帐号是2013年5月1日前注册,并且在这时间之前有发布代码操作。 完成任务,总金额奖励30元人民币或者30元话费赠送。(目前只支持支付宝) http://user.qzone.qq.com/2810652416/blog/1383705639#!app=2&via=QZ.HashRefresh&pos=1383705639

  • 成长者

    成长者 2016-06-03 22:40:00

    四楼正解 git rm --cached filename git commit -m &quot;hehe&quot; git push origin branch 四楼正解 git rm --cached filename git commit -m &quot;hehe&quot; git push origin branch 刚学了pro git,现学现卖,亲测有效。。 --cached 的指令 都是和staging area或者叫index有关的,就是git add了但还没有commit出去的状态。 git rm --cached filename 把文件从staging area中删了,再commit,push,就把github里面那份也删了。 ... justashotaway

    正解,多谢啦

  • jero

    jero 2016-06-05 22:52:09

    楼主我的使用如下命令删除不了,怎么办 git rm --cached filename git commit -m "hehe" git push origin branch 现在出现如下错误 error: src refspec branch does not match any. error: failed to push some refs to 'https://github.com/kekekeke8/UCore.git'

你的回应

回应请先 , 或 注册

git
2788 人聚集在这个小组
↑回顶部