What is covered in this part
- What version control, push, and pull mean
- Version control
- Push
- Pull
- A Practical Example(Part 4)
What is the meaning of Version control, Push and Pull
Version control (Git)
Version control is a system that records changes to your files over time.
In simple terms, it’s like having a save history for your project. With Git, you create checkpoints called commits. Each commit becomes part of your project history, so you can see what changed, know when it changed and go back to an earlier version if needed.
So if something breaks or you realize you preferred an older version, you can easily go back to it instead of starting over.
Here are some commands to keep in mind:
git status— Shows which files have changed and whether those changes have already been committed. Only committed changes can be pushed.
git add .— Tells Git to include all changed files in the next commit.
git commit -m "..."— Creates the checkpoint (commit) with a message.
git log— Displays a list of all commits. It displays who made the change, when, and the commit message.
git showorgit show <commit-id>— Shows the actual lines that were added or removed. It is useful when you want to understand what changed.
git restore filename(e.g.notes.txt) — Reverts the file back to the last saved commit. It is useful if you made a mistake and want to undo it.
git checkout <commit-id>(e.g.a1b2c3d) — Lets you look at an older version of the project without deleting your work. It is useful when learning.
git checkout main— Lets you return to the latest version.
git restore filename— Lets you undo changes to a file (i.e. go back to last saved version).
Push
Push means sending your saved commits from your computer (local repository) to GitHub (remote repository). When you push:
- your work and changes are uploaded to GitHub,
- they are backed up online,
- they become available for sharing or collaboration.
If you don’t push, your work remains only on your computer and isn’t visible or backed up on GitHub.
Here are some commands to keep in mind:
If it is your first time pushing a repository, you may need: git push -u origin main(change main to master if your branch is master).
Use git branch(or git status) If you want to check which branch you are working on.
If you want to switch to main, use git branch -M main command.
After your first push, you can just use git push.
You should also note that before pushing, changes must be saved as commits using git add and git commit. When you push, your local commits are uploaded to GitHub so they are stored online, backed up, and available for others to see.
Pull
Pull means downloading the latest commits from GitHub (remote repository) to your computer (local repository).
This is important when:
You work on multiple computers and need the same files everywhere.
You collaborate with others and want their latest changes. For example, group or teams projects.
Updates were made directly on GitHub and you need them on your local machine.
Here are some commands to keep in mind:
git pull- Lets you download the latest commits from GitHub and updates your local files.
git fetch- checks for update without installing them.
This command lets you download updates from GitHub without changing your local files. It simply checks for new commits and brings that information into your local repository so you can see what has changed.
Unlikegit pull, fetching does not automatically update your working files. This makes it useful when you want to review updates first or confirm that changes exist before applying them.
git merge- Lets you now combine the updates fetched(git fetch) with your files.
There are other command prompts, such as git pull --rebase, git restore, git reset --hard, which will be covered later in the series.
A Practical Example: Tracking Changes and Pushing to GitHub and Pulling from GitHub (Pending)
Now that we understand what version control, push, and pull mean, let’s walk through a simple example to see how these commands work together in practice in Part 4 of the series where we will also look into other command.
SOCIAL SHARE CARD GENERATOR