Commit, Push and Pull
Most days you only need five commands — or one panel in VS Code.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Nov 25, 2026
Learning objectives#
- Read git status
- Stage and commit changes
- Push commits to GitHub
- Pull other people’s commits
Explanation#
git status tells you which files changed (modified), which are new (untracked) and which are staged. Run it whenever you are unsure.
git add <file> stages a file; git add . stages everything in the folder. git commit -m "message" saves the staged changes as one commit.
git push uploads your commits. If someone else pushed first, Git rejects your push and asks you to pull: git pull downloads their commits and merges them with yours, then you push again.
VS Code does the same in the Source Control panel (Ctrl+Shift+G): click + to stage, type the message, click Commit, then Sync Changes to pull and push in one step.
Step-by-step screens#
Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: One round of the daily loop#
git pull # start with the latest version
# ...edit index.html and add contact.html...
git status
git add .
git commit -m "Add contact page"
git push
Already up to date.
On branch main
Changes not staged for commit:
modified: index.html
Untracked files:
contact.html
[main 7c1d9e2] Add contact page
2 files changed, 24 insertions(+)
To https://github.com/asha/hello-github.git
3f9c2a1..7c1d9e2 main -> mainThis example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- pull first so you build on the latest code.
- status shows one modified and one new file.
- add . stages both.
- commit saves them with a message.
- push uploads the new commit to GitHub.
Real-world use case#
Two friends build a website together: each pulls in the morning, commits small changes and pushes several times a day, so their work rarely collides.
Common mistakes#
Someone pushed first. Run git pull, fix any conflict, then push again — never use --force on a shared branch.
Logs, node_modules and .env get committed. Add a .gitignore before the first commit.
Best practices#
- Pull before you start
- Commit small and often
- Read git status before committing
- Push at the end of each work session
Remember this#
status → add → commit → push.
Rejected push? pull, then push.
VS Code: + , message, Commit, Sync.
Practice exercise#
Your task: Stage only README.md and commit it with the message “Update README”.
Show solution
git add README.md
git commit -m "Update README"
Mini quiz#
Your push is rejected because the remote has new commits. What do you do first?
Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions
My notes#
Saved in this browser.