Local Commits Made Simple
Git is a free and open-source version control system that helps developers manage code changes efficiently. One of the most essential habits to build as a developer is to commit early and commit often.
This practice helps you:
- Prevent loss of work
- Create clean and understandable commit histories
- Debug faster by isolating changes
- Collaborate smoothly with others or even your future self
Why You Should Commit Often
Here are a few reasons why frequent, focused commits are better than one massive commit at the end:
- Easier to Track: Each change has a purpose and a message.
- Rollback Friendly: Mistakes can be undone one commit at a time.
- Readable History: Future developers will thank you for this.
Local Git Examples (No GitHub Required)
Example 1: Initializing a New Repository and First Commit
mkdir my_project
cd my_project
git init
echo "print('Hello, world!')" > hello.py
git add hello.py
git commit -m "Initial commit: Add hello.py with Hello World message"
This creates a new Git repository, adds a Python file, and makes the first meaningful commit. Always describe the change in your commit message.
Example 2: Making a Small Update and Committing Again
echo "print('Welcome to Git Best Practices!')" >> hello.py
git add hello.py
git commit -m "Update hello.py: Add welcome message"
A small change was made and committed immediately. This keeps the history clean and focused.
Example 3: Fixing a Typo or Bug
nano hello.py # (fix typo or bug in the code manually)
git add hello.py
git commit -m "Fix typo in welcome message"
Even small fixes deserve their own commit. This helps track what was fixed and when.
Screenshots and Screencast Tutorial



More Resources From Edward Ojambo
-
Programming Books:
Get my books here:
https://www.amazon.com/stores/Edward-Ojambo/author/B0D94QM76N -
Online Programming Courses:
Take my courses on various programming topics:
https://ojamboshop.com/product-category/course -
1-on-1 Programming Tutorials:
Book a session for personal help:
https://ojambo.com/contact -
Git Installation & Repository Migration:
Need Git installed or want to migrate your code? Contact me:
https://ojamboservices.com/contact
Final Thoughts
Start with small, descriptive commits and build up a habit of frequent saves. Your project history becomes your best documentation and backup. Remember:
Commit Early. Commit Often.
If you found this helpful, feel free to share it or reach out with questions. Happy coding!