What is Git?
What is GitHub?
What is to Push, to pull and Track changes?
Well, easy... buckle up, get a glass of water and let us begin.
Git
Git is a free, open-source version control system that helps developers track changes in their code, collaborate with others, and manage project history efficiently.
What Git Does
- Tracks changes: Git records every modification made to files over time.
- Restores versions: You can roll back to earlier versions if something breaks.
- Supports collaboration: Multiple people can work on the same project without overwriting each other’s work.
- Keeps history: Git logs who made changes, when, and why.
Why Git Is Powerful
- Distributed system: Every developer has a full copy of the project history, not just the latest version.
- Speed & efficiency: Handles projects of all sizes quickly.
- Flexibility: Works with command-line tools, GUIs, and hosting services like GitHub.
Example
Imagine you’re writing a research paper:
Without Git → You’d keep saving files as paper_v1.docx, paper_v2.docx, etc. Chaos!
With Git → You commit changes, add notes, and can always go back to a previous version. Much cleaner and safer.
In short: Git is your project’s memory and safety net. It ensures you never lose work, can experiment freely, and collaborate without fear of overwriting someone else’s progress.
Sip some water
Now, allow me to introduce the word Version Control
Definition: Version control (also called source control) is a system that records changes to files in a special database.
Purpose: It ensures that every modification is tracked, so you can compare, undo, or merge changes safely.
Collaboration: Multiple people can work on the same project without overwriting each other’s work.
The Correlation between Git and Version Control
• Version control is the concept.
• Git is the tool that makes version control possible.
In other words: Git is the practical implementation of version control.
Why version Control is important
• Safety net: If a mistake is made, you can roll back to a previous version.
• Transparency: You can see who made changes, when, and why.
• Efficiency: Teams work faster and smarter, especially in DevOps and agile environments.
• Organization: No more chaotic file names like project_final_really_final.py.
How to push code to GitHub
Pushing code to GitHub means sending your project from your local computer (where you’re coding) to GitHub (the cloud repository).
Here’s a clear step‑by‑step guide:
Steps to Push Code to GitHub
- Initialize Git in Your Project Open Git Bash in your project folder and run:
git init
This tells Git to start tracking changes in that folder.
- _ Add Your Files_ Stage all files so Git knows which ones to include:
git add .
( means “add everything in this folder.”)
- Commit Your Changes Save a snapshot of your project with a message:
git commit -m "Initial commit"
The message should describe what you changed.
- Connect to GitHub • Go to GitHub and create a new repository (e.g., ). • Copy the repo link (choose HTTPS or SSH). • Add it as a remote:
git remote add origin https://github.com/YourUsername/my-first-repo.git
• (Replace with your actual repo link.)
- Push Your Code Finally, send your code to GitHub:
git push -u origin main
• origin → the remote repository on GitHub.
• main → the branch you’re pushing (default branch).
Quick Recap
-
git init→ start Git in your folder -
git add→ stage files -
git commit-m"message"→ save snapshot -
git remote add origin <repo-link>→ connect to GitHub -
git push -u origin main→ upload code
You have successfully pushed code to GitHub
How to pull code from GitHub
Pulling code from GitHub means downloading the latest changes from a repository on GitHub to your local computer. This keeps your local project up to date with what’s stored online.
Here’s a clear step- by -step guide:
- Navigate to Your Project Folder Open Git Bash (or your terminal) and move into the folder where your project is stored:
cd path/to/your/project
- Check Your Remote Connection Make sure your local repo is connected to GitHub:
git remote -v
You should see something like:
origin https://github.com/YourUsername/repo-name.git (fetch)
origin https://github.com/YourUsername/repo-name.git (push)
- Pull the Latest Changes Run:
git pull origin main
-
origin→ the remote repository on GitHub. -
main→ the branch you want to update (sometimes it’s master or another branch).
This command fetches changes from GitHub and merges them into your local project.
- Resolve Merge Conflicts (if any)
If you and someone else edited the same file differently, Git will ask you to resolve conflicts manually.
- Open the file, look for conflict markers (<<<<<<<, =======, >>>>>>>).
- Edit the file to keep the correct version.
- Then commit the resolved file:
git add filename
git commit -m "Resolved merge conflict"
Quick Recap
-
cd project-folder→ go to your repo -
git remote -v→ check connection -
git pull origin main→ download changes - Resolve conflicts if needed
You’ve successfully pulled code from GitHub.
How to track changes using Git
Tracking changes is one of the most powerful features of Git. It lets you see what’s happening in your project, what files have been modified, and the history of every change.
Here’s a breakdown:
Key Git Commands for Tracking Changes
- Check the Status
git status
• Shows which files are new, modified, or staged for commit.
• Example output:
modified: analysis.py
untracked files: report.csv
- View Commit History
git log
• Displays a list of commits with messages, authors, and dates.
• Helpful for understanding the timeline of your project.
• Add --oneline for a cleaner view:
git log --oneline
- Compare Changes
git diff
• Shows the exact lines that changed in your files.
• Example:
- print("Hello World")
+ print("Hello Git")
- Track Specific Files
git add filename
• Stages a file so Git starts tracking it.
• Once tracked, changes to that file will appear in git status and git diff.
- Undo Staged Changes
git reset filename
• Removes a file from staging if you added it by mistake.
Workflow Example
- Edit your code.
- Run
git status→ see what changed. - Run
git diff→ check the exact modifications. - Run
git add→ stage changes. - Run
git commit -m "Update analysis script"→ save snapshot. - Run
git log→ confirm your commit is recorded.
In short: Git tracks changes through status, diffs, commits, and logs. These commands give you full visibility into your project’s evolution.
Final Thoughts
Git and GitHub may feel overwhelming at first, but once you practice the basics push, pull, commit, and track changes you’ll see how powerful they are. They’re not just tools; they’re the backbone of modern software development and data science collaboration.
Pro tip: Start small. Create a simple project (like a Python script or dataset analysis), push it to GitHub, make a few changes, and practice pulling and tracking. The more you use Git, the more natural it becomes.
Thank you for reading! If this helped you, feel free to leave a comment or share your Git journey below.
Top comments (0)