A commit records a snapshot of code changes in Git’s version history and attaches a short message describing those changes. Before committing, Git stages files with git add; afterward, the snapshot can be pushed to a remote repository for others to access. section 2.3 section 2.3.2
A practical commit workflow is:
- Run git status to find created or modified files that are not yet committed. section 2.3.2
- Run git add . for all changed files, or git add [file_name] for a specific file, placing changes in Git’s staging area. section 2.3 section 2.3.2
- Run git commit -m "message" to save the staged changes as a snapshot with a description. section 2.3
- Run git push to submit the local commit to a remote repository so collaborators can download or view it. section 2.3.2
Each commit has a unique hash ID. Use git log to list commits and git show followed by a hash to inspect the commit’s code changes. section 2.3.3 section 2.3.3
Commit a data-processing script
After creating 1_process_data.py, check its status, stage it, and save it with a descriptive message: git status; git add 1_process_data.py; git commit -m "create 1_process_data.py for processing data". Push the commit afterward when collaborators need the updated codebase. section 2.3.2 section 2.3.2
Listing 2.7 git commit saves the changes you’ve made as a snapshot of the repo. The parameter -m is used to include a message / description for the commit.
git commit -m "upload initial set of files" #1
See the complete git commit command, including the -m parameter for recording a snapshot description. section 2.3







