Can I make a user-specific gitignore file?

后端 未结 5 470
陌清茗
陌清茗 2020-11-28 23:44

I want to change the gitignore, but not everyone on the team wants these changes. How can a user have their own specific git ignore file?

相关标签:
5条回答
  • 2020-11-29 00:34

    For example, you want ignore ~/some/path/.idea folder:

    # 1. Add .idea to user specific gitignore file
    echo .idea > ~/.gitignore
    
    # 2. Add gitignore file to gitconfig
    git config --global core.excludesfile ~/.gitignore
    
    0 讨论(0)
  • 2020-11-29 00:36

    You can create your own .gitignore using

    git config --global core.excludesfile $HOME/.gitignore
    

    Then put your desired entries in that file.

    0 讨论(0)
  • 2020-11-29 00:37

    As indicated in Atlassian's .gitignore tutorial, you could also use your repo's <repo>/.git/info/exclude file that you can easily edit with any text editor. It works the same as .gitignore.

    I could easily ignore my intelliJ files, personal dockerfiles and stuff only I need to work with.

    0 讨论(0)
  • 2020-11-29 00:43

    For user-specific and repo-specific file ignoring you should populate the following file:

    $GIT_DIR/info/exclude

    Usually $GIT_DIR stands for:

    your_repo_path/.git/

    0 讨论(0)
  • 2020-11-29 00:48

    In their .gitconfig:

    [core]
        excludesfile = ~/.global_gitignore
    

    That way, they can ignore certain types of files globally. Each user can have their own global ignore file.

    0 讨论(0)
提交回复
热议问题