What is .gitignore exactly?

前端 未结 5 880
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 01:05

I just created a Github repository and was wondering what the .gitignore file was for. I started by not creating one, but added one due to the fact that most re

5条回答
  •  一个人的身影
    2020-11-28 01:46

    There are files you don't want Git to check in to. Git sees every file in your working copy as one of three things:

    1. tracked - a file which has been previously staged or committed;
    2. untracked - a file which has not been staged or committed; or
    3. ignored - a file which Git has been explicitly told to ignore.

    Ignored files are usually built artifacts and machine-generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:

    • dependency caches, such as the contents of /node_modules or /packages
    • compiled code, such as .o, .pyc, and .class files
    • build output directories, such as /bin, /out, or /target
    • files generated at runtime, such as .log, .lock, or .tmp
    • hidden system files, such as .DS_Store or Thumbs.db
    • personal IDE config files, such as .idea/workspace.xml

    Ignored files are tracked in a special file named .gitignore that is checked in at the root of your repository. There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. .gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored. Here is a sample.gitignore file. For more details look at this link

提交回复
热议问题