Is there an ignore command for git like there is for svn?

后端 未结 11 2502
一个人的身影
一个人的身影 2020-12-23 00:21

I am a new user to git and I am starting a new project. I have a bunch of dot files that I would like to ignore. Is there an ignore command for git

相关标签:
11条回答
  • 2020-12-23 00:54

    A very useful git ignore command comes with the awesome tj/git-extras.

    Here are a few usage examples:

    List all currently ignored patterns

    git ignore
    

    Add a pattern

    git ignore "*.log"
    

    Add one of the templates from gitignore.io

    git ignore-io -a rails
    

    git-extras provides many more useful commands. Definitely worth trying out.

    0 讨论(0)
  • 2020-12-23 00:56

    You have two ways of ignoring files:

    • .gitignore in any folder will ignore the files as specified in the file for that folder. Using wildcards is possible.
    • .git/info/exclude holds the global ignore pattern, similar to the global-ignores in subversions configuration file.
    0 讨论(0)
  • 2020-12-23 00:56

    Create a file named .gitignore on the root of your repository. In this file you put the relative path to each file you wish to ignore in a single line. You can use the * wildcard.

    0 讨论(0)
  • 2020-12-23 00:57

    You have to install git-extras for this. You can install it in Ubuntu using apt-get,

    $ sudo apt-get install git-extras
    

    Then you can use the git ignore command.

    $ git ignore file_name
    
    0 讨论(0)
  • 2020-12-23 01:04

    On Linux/Unix, you can append files to the .gitignore file with the echo command. For example if you want to ignore all .svn folders, run this from the root of the project:

    echo .svn/ >> .gitignore
    
    0 讨论(0)
提交回复
热议问题