代码之家  ›  专栏  ›  技术社区  ›  Chris J

git是否有类似svn的ignore命令?

  •  132
  • Chris J  · 技术社区  · 16 年前

    git 就像有 svn

    10 回复  |  直到 9 年前
        1
  •  124
  •   ndim    14 年前

    git ignore

    .gitignore 然后提交。克隆该仓库的每个人都会忽略这些文件。

    / 位于。其他所有内容都将与任何子目录中的文件匹配。

    .git/info/exclude .git/info/reclude

    您还可以设置一个全局文件,其中包含要忽略的模式 git config --global core.excludesfile 。这将在本地应用于同一用户帐户上的所有git工作副本。

    git help gitignore 并阅读文本以了解详细信息。

        2
  •  84
  •   Antoine Nitish Kumar    10 年前

    git ignore tj/git-extras .

    以下是一些使用示例:

    git ignore
    

    git ignore "*.log"
    

    gitignore.io

    git ignore-io -a rails
    

    git-extras 提供了更多有用的命令。绝对值得一试。

        3
  •  46
  •   M--    8 年前

    在Linux/Unix上,您可以使用以下命令将文件附加到.gitignore文件中 echo 命令。例如,如果你想忽略所有 .svn

    echo .svn/ >> .gitignore
    
        4
  •  15
  •   bluebrother    16 年前

    有两种方法可以忽略文件:

    • .gitignore
    • .git/info/exclude 保持全局忽略模式,类似于 global-ignores
        5
  •  4
  •   Nesar    8 年前

    *

        6
  •  3
  •   David Gardiner    10 年前

    定义一个完整的 为您的项目创建文件。奖励是安全使用方便 --all -a 标记命令,如 add commit .

    *~

        7
  •  2
  •   Community Mohan Dere    9 年前

    git ignore alias

    ignore = !sh -c 'echo $1 >> .gitignore' -
    

    或者从您选择的(*nix)shell运行此命令:

    git config --global alias.ignore '!sh -c "echo $1 >> .gitignore" -'
    

    git exclude 通过替换命令 ignore exclude .gitignore .git/info/exclude

    this question

        8
  •  1
  •   seh Alexei    16 年前

    $ sudo apt-get install git-extras
    

    $ git ignore file_name
    
        9
  •  1
  •   Vidura Mudalige    8 年前

    echo /globpattern >> .gitignore
    

    或者对于现有文件(sh类型命令行):

    echo /$(ls -1 file) >> .gitignore   # I use tab completion to select the file to be ignored  
    git rm -r --cached file             # if already checked in, deletes it on next commit
    
        10
  •  1
  •   nrbray    8 年前

    你也可以使用乔·布劳的gitignore.io

    https://www.gitignore.io/

    或者通过安装CLI工具,这非常简单,只需在终端上键入以下命令即可:


    echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bashrc && source ~/.bashrc

    OSX:
    echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bash_profile && source ~/.bash_profile

    然后你就可以打字了 gi 接下来是您需要gitignore标准的所有平台/环境元素。

    例子!

    gi linux,webstorm,node,grunt > .gitignore

    gi linux,webstorm,node,grunt >> .gitignore (将新规则附加/添加到现有文件中)

    砰,你可以走了

        11
  •  0
  •   JorgeArtware    11 年前