Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

git
communitycreator

What are the differences between .gitignore and .gitkeep?

Gutha Vamsi Krishna

Overview

Git is a free and open-source distributed version control system.

The .gitignore file

Sometimes 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_STORE
node_modules
scripts/flow/*/.flowconfig
.flowconfig
*~
*.pyc
.grunt
_SpecRunner.html
__benchmarks__
build/
remote-repo/
coverage/
.module-cache
fixtures/dom/public/react-dom.js
fixtures/dom/public/react.js
test/the-files-to-test.generated.js
*.log*
chrome-user-data
*.sublime-project
*.sublime-workspace
.idea
*.iml
.vscode
*.swp
*.swo

packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/chrome/*.crx
packages/react-devtools-extensions/chrome/*.pem
packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/firefox/*.xpi
packages/react-devtools-extensions/firefox/*.pem
packages/react-devtools-extensions/shared/build
packages/react-devtools-extensions/.tempUserDataDir
packages/react-devtools-inline/dist
packages/react-devtools-shell/dist
packages/react-devtools-timeline/dist

The .gitkeep feature

The .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.

RELATED TAGS

git
communitycreator
RELATED COURSES

View all Courses

Keep Exploring