Git is a free and open-source distributed version control system.
.gitignore
fileSometimes while adding files and folders, we may want to exclude secret or unwanted ones.
For this exact reason, Git provides a feature called gitignore
. We create a file called .gitignore
and add a list of files or folders that we don't want to add to the Git repository. It will ignore the files/folders present in the .gitignore
file.
Some popular frameworks or libraries will create a .gitignore
file automatically and add unwanted or secret files/folders to it.
An example of a .gitignore
file of a React project is given below.
Note: You can easily find what to ignore for your project by searching in Github.
.DS_STOREnode_modulesscripts/flow/*/.flowconfig.flowconfig*~*.pyc.grunt_SpecRunner.html__benchmarks__build/remote-repo/coverage/.module-cachefixtures/dom/public/react-dom.jsfixtures/dom/public/react.jstest/the-files-to-test.generated.js*.log*chrome-user-data*.sublime-project*.sublime-workspace.idea*.iml.vscode*.swp*.swopackages/react-devtools-core/distpackages/react-devtools-extensions/chrome/buildpackages/react-devtools-extensions/chrome/*.crxpackages/react-devtools-extensions/chrome/*.pempackages/react-devtools-extensions/firefox/buildpackages/react-devtools-extensions/firefox/*.xpipackages/react-devtools-extensions/firefox/*.pempackages/react-devtools-extensions/shared/buildpackages/react-devtools-extensions/.tempUserDataDirpackages/react-devtools-inline/distpackages/react-devtools-shell/distpackages/react-devtools-timeline/dist
.gitkeep
featureThe .gitkeep
feature is not a part of Git, but it is a trick we use to add empty directories to a Git repository.
Generally, Git doesn't add empty directories and sometimes we may need to add them to a Git repository. So, we create a .gitkeep
file under the empty directory so that the directories are added to the repository.
Note: We can use any name like
.empty
or.keep
; it doesn't necessarily need to be.gitkeep
.