Git - Creating a .gitignore file

后端 未结 4 1313
闹比i
闹比i 2020-11-30 03:31

I\'m looking to create a .gitignore file so certain files are do not get checked in to the repository. Does anyone have a guide on how and where to place this f

4条回答
  •  我在风中等你
    2020-11-30 03:45

    Placement of .gitignore depends if the files need to be ignored for just one repo or for all your repos. For one repo, place it in the root of your repo.

    When you create a .gitignore file in an existing repo, or add files that were already in the repo, you have to make sure to remove the to-be-ignored files from the repo.

    If you have a test.dll in the root, you have to do

    git rm --cached test.dll
    

    Now if you have a lot of files, like you said you can opt for the following option, remove everything from the cache, add it all back (the files in .gitignore will not be added) and commit everything again.

    git rm -r --cached .
    git add .
    git commit -m "Start using .gitignore"
    

提交回复
热议问题