Utilize common version control operations with Git
📘Cisco DevNet Associate (200-901 DEVASC)
For the Cisco DevNet Associate exam, you must clearly understand how Git commits work, why they are important, and how they are used in software development and IT environments such as automation projects, API integrations, and infrastructure-as-code repositories.
This section explains everything you need to know about Git commit in simple and easy English.
1. What is Git?
Git is a distributed version control system used to track changes in files.
In IT environments, Git is commonly used for:
- Source code management
- Network automation scripts
- API integration projects
- Infrastructure-as-code (IaC) configurations
- DevOps pipelines
Git helps teams:
- Track changes
- Work together safely
- Roll back to previous versions
- Maintain history of changes
2. What is a Commit?
A commit in Git is a snapshot of your project at a specific point in time.
When you commit:
- Git saves the current changes
- It creates a unique ID (called a commit hash)
- It stores author information
- It stores date and time
- It stores a commit message
Think of a commit as a saved version of your project.
3. Why Commit is Important in IT Environments
In real IT environments, commits are used for:
1. Tracking Code Changes
Example:
- Updating a Python script that calls a REST API
- Modifying network automation playbooks
- Changing configuration files
Each commit records:
- What changed
- Who changed it
- When it was changed
- Why it was changed (from the commit message)
2. Troubleshooting
If a new update breaks an automation script:
- You can go back to a previous commit
- Compare changes between commits
- Identify which change caused the issue
3. Collaboration
When multiple developers work on:
- An API integration
- A CI/CD pipeline
- A configuration repository
Each developer makes commits to track their changes clearly.
4. Git Workflow Before Commit
Before understanding commit, you must understand Git’s three main areas:
1. Working Directory
This is where you edit files.
2. Staging Area (Index)
This is where you prepare files for commit.
3. Repository (.git directory)
This is where commits are permanently stored.
Basic Flow:
Working Directory → Staging Area → Commit (Repository)
5. Basic Commit Commands
1. Check Status
git status
Shows:
- Modified files
- New files
- Deleted files
- Files staged for commit
2. Add Files to Staging Area
git add filename
Add all files:
git add .
This prepares files for commit.
3. Commit the Changes
git commit -m "Your commit message"
Example:
git commit -m "Updated REST API authentication logic"
The -m flag allows you to write a commit message directly.
6. What Happens During a Commit?
When you run:
git commit -m "message"
Git:
- Creates a snapshot of staged files
- Generates a unique commit ID (SHA-1 hash)
- Stores metadata:
- Author
- Date/time
- Commit message
- Links it to the previous commit
Commits form a chain called the commit history.
7. Commit Hash (SHA-1)
Each commit has a unique identifier like:
a1b2c3d4e5f6...
This is called a commit hash.
It allows you to:
- Reference specific commits
- Compare commits
- Revert changes
8. Viewing Commit History
View all commits:
git log
Shows:
- Commit ID
- Author
- Date
- Message
Short version:
git log --oneline
Useful for quickly viewing history.
9. Good Commit Messages (Exam Important)
A commit message should:
- Be clear
- Be short
- Describe what changed
- Explain why if needed
Good examples:
Fix API timeout issue
Add input validation to login endpoint
Update network automation script for VLAN support
Bad examples:
Changes
Update
Fixed stuff
For DevNet exam understanding:
Clear commit messages are critical in professional IT environments.
10. Amending a Commit
If you made a mistake in the last commit:
git commit --amend
This allows you to:
- Change commit message
- Add missed files
⚠ Important:
Do NOT amend commits that are already pushed to a shared repository (unless you understand rewriting history).
11. Committing All Modified Files
Instead of:
git add .
git commit -m "message"
You can use:
git commit -a -m "message"
This:
- Automatically stages modified tracked files
- Does NOT stage new untracked files
12. Difference Between git add and git commit
| Command | Purpose |
|---|---|
git add | Moves changes to staging area |
git commit | Saves staged changes permanently |
Many exam questions test this difference.
13. Best Practices for Commits (Exam Focus)
1. Commit Often
Small commits are better than one large commit.
2. One Logical Change per Commit
Example:
- One commit for API change
- One commit for configuration update
3. Write Clear Messages
4. Do Not Commit Sensitive Data
Never commit:
- Passwords
- API keys
- Tokens
- Private certificates
In DevNet environments, sensitive data should be managed using secure vaults or environment variables.
14. Commit in DevNet and Automation Context
In Cisco DevNet-style projects, commits are used for:
- Python automation scripts
- REST API clients
- JSON/YAML configuration files
- CI/CD pipeline scripts
- Dockerfiles
- Infrastructure templates
Example scenario:
You modify a Python script that connects to a network device API.
You test the change.
You stage the file.
You commit with a message:
Add error handling for device authentication failure
This makes project history clear and professional.
15. Common Exam Confusions
1. Commit vs Push
git commit→ Saves changes locallygit push→ Sends commits to remote repository
Commit does NOT automatically push.
2. Staging is Required
Git only commits what is staged.
Unstaged changes are not included.
3. Each Commit is Permanent (History)
Commits build a timeline.
They allow:
- Reverting
- Comparing
- Branching
16. Summary – What You Must Remember for the Exam
You should clearly understand:
✔ What a commit is
✔ The difference between working directory, staging area, and repository
✔ How to use git add and git commit
✔ What a commit message is
✔ How to view commit history (git log)
✔ What a commit hash is
✔ The purpose of git commit -a
✔ The purpose of git commit --amend
✔ Why commit messages matter
✔ The difference between commit and push
Final Simple Definition
A commit in Git is a saved snapshot of staged changes in a repository, including metadata and a message, used to track project history and enable collaboration.
