V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
kchum
V2EX  ›  git

我用 git 的忽略列表的方式是不是错了?没有成功忽略过文件

  •  
  •   kchum · 2014-03-29 03:05:10 +08:00 · 4289 次点击
    这是一个创建于 3683 天前的主题,其中的信息可能已经有所发展或是发生改变。


    看了 http://git-scm.com/book/zh/Git-%E5%9F%BA%E7%A1%80-%E5%8F%96%E5%BE%97%E9%A1%B9%E7%9B%AE%E7%9A%84-Git-%E4%BB%93%E5%BA%93 ,比较简洁,好像也没特殊操作啊
    弄了一晚上了,还不行,开放模式.php,都没效果。。其中远端库都删了好几次.git,都重新init了.

    其实就是不想在修改代码多的时候git add 一条条加代码,很麻烦,想用git commit -a。
    环境是Mac Mavericks 10.9.2,git 1.8.5.2
    大家帮看下是什么问题产生的,还是我的操作方式有误?!
    谢谢大家!
    10 条回复    1970-01-01 08:00:00 +08:00
    csslayer
        1
    csslayer  
       2014-03-29 03:37:17 +08:00   ❤️ 2
    git 不会忽略一个已经被 track 的文件

    你可以试试这里列出的方法看看哪个适合你

    http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-gitignored
    mclxly
        2
    mclxly  
       2014-03-29 08:40:20 +08:00   ❤️ 1
    兄弟,你这种忽略文件的方法很奇葩呀。

    你在项目根目录下添加.gitignore这个文件(其实随便那个目录下都可以添加此文件,然后写该目录的忽略选项),然后在里面添加需要忽略的路径或者文件。

    ----------------------------------example
    #OS junk files
    [Tt]humbs.db
    *.DS_Store

    #Visual Studio files
    *.[Oo]bj
    *.user
    *.aps
    *.pch
    RIcter
        3
    RIcter  
       2014-03-29 09:13:11 +08:00 via iPhone   ❤️ 1
    1。先把那个文件copy一份到别处
    2。然后git remove config.inc.php
    3。再copy回去
    panlilu
        4
    panlilu  
       2014-03-29 09:32:33 +08:00 via iPhone   ❤️ 1
    git rm
    2code
        5
    2code  
       2014-03-29 09:36:27 +08:00   ❤️ 1
    cp path/of/file /some/other/path
    git rm path/of/file
    git commit -m "rm config file"
    echo "path/of/file" > .gitignore
    cp /some/other/path path/of/file
    kchum
        6
    kchum  
    OP
       2014-03-29 10:06:01 +08:00 via iPad
    感谢楼上各位,不一一@了。

    @mclxly 我也是用.gitignore啊,不都是这样用么。如果你说的是.gitignore和exclude的内容,那是测试的,怀着再不济总有一行会生效的想法
    yangg
        7
    yangg  
       2014-03-29 10:43:37 +08:00   ❤️ 1
    不会忽略已经track的文件,
    git rm --cached path/to/file # remove file from git index.
    derek80
        8
    derek80  
       2014-03-29 13:43:43 +08:00   ❤️ 1
    一直用 https://github.com/github/gitignore 然后定义些自已得。
    bsbgong
        9
    bsbgong  
       2014-03-29 16:25:49 +08:00 via iPhone   ❤️ 1
    git rm -r --cached folder/ #设置本地哪些目录的修改将被git忽略
    执行后查看git status,git不会track你刚刚设置的目录了
    xi_lin
        10
    xi_lin  
       2014-03-29 18:59:02 +08:00   ❤️ 2
    如果要忽略已经track文件的修改,可以用--assume-unchanged

    实在不行你在github上放一个示例项目看看。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1460 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:12 · PVG 01:12 · LAX 10:12 · JFK 13:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.