The Basic Git Commit Workflow
- Make Changes
- Add Changes
- Commit
1. Make Changes
Make new files, edit files, delete files, etc. in a location that is tracked by Git.
2. Add Changes
Group specific changes together, in preparation of committing. The changes added in this step are not committed yet to the repo. Consider this step as a Staging step/area.
git add [file1] [file2]
Explicitly add the files to be added.
git add .
Stage ALL changes at once.
3. Commit
Commit everything that was previously added.
git commit -m "Describe the commit here"
The -m
flag is to pass an inline commit message. Without this flag, a text editor will be launched to give a commit message.
Ignoring Files
There are some files that should not be committed such as:
- Temporary files, build results, and files generated by an IDE
- Secrets, API keys, credentials, etc.
- Log files
- Dependencies & packages
To ignore those files create .gitignore file in the root of a repo. Inside the file, write patterns to tell git which files & folders to ignore.
See this example of ignoring files generated by Visual Studio.
Top comments (0)