How to stop tracking and ignore changes to a file in Git?

前端 未结 20 1773
梦谈多话
梦谈多话 2020-11-21 07:17

I have cloned a project that includes some .csproj files. I don\'t need/like my local csproj files being tracked by Git (or being brought up when c

20条回答
  •  我寻月下人不归
    2020-11-21 07:36

    An almost git command-free approach was given in this answer:

    To ignore certain files for every local repo:

    1. Create a file ~/.gitignore_global, e.g. by touch ~/.gitignore_global in your terminal.
    2. Run git config --global core.excludesfile ~/.gitignore_global for once.
    3. Write the file/dir paths you want to ignore into ~/.gitignore_global. e.g. modules/*.H, which will be assumed to be in your working directory, i.e. $WORK_DIR/modules/*.H.

    To ignore certain files for a single local repo:

    1. Do the above third step for file .git/info/exclude within the repo, that is write the file/dir paths you want to ignore into .git/info/exclude. e.g. modules/*.C, which will be assumed to be in your working directory, i.e. $WORK_DIR/modules/*.C.

提交回复
热议问题