Git Procedure for Beginners#
Before asking for help, please first search the issue on Google or ask an AI assistant. If the problem persists, then ask a colleague.
Introduction#
Git is a version control system used to manage code changes. A key concept in Git is the branch.
What is a branch?#
A branch is a copy of the code where you can work independently without affecting the main version. This allows multiple people to work in parallel.
Two types of branches:
Local: Exists only on your computer.
Remote: Shared on GitHub (or another server, but here GitHub).
You’ll often need to:
Merge updates from
main
into your branchPush your own changes to
main
You only need a few commands to do this.
Prerequisite: You should have Git installed on your computer.
Keeping Your Branch Up to Date#
main
→ my-branch
To get the latest updates from main
into your branch:
Switch to your branch:
git checkout my-branch
Fetch updates from
main
:git fetch origin main
Merge them into your branch:
git merge origin/main
If Git shows conflicts, open the listed files, make corrections, then run:
git add .
git commit -m "Resolve merge conflicts"
Pushing Changes from Your Branch to main
#
my-branch
→ main
Once your updates are tested, you may want to move selected changes into main
.
Switch to
main
:# Make sure you're on your branch git checkout main # Save and stage your changes git add . git commit -m "Describe your changes" # Push your branch to GitHub git push origin my-branch
View your commit history:
git log --oneline
Summary of Key Commands#
Action |
Command |
---|---|
Switch to your branch |
|
Fetch updates from |
|
Merge changes into your branch |
|
Pull updates from |
|
Switch to |
|
View commit history |
|
Push changes to |
|
Final Tips#
Use
git status
to see what’s going onUse
git log --oneline
to see commit historyUse Google or AI tools for troubleshooting
Ask teammates only after checking the basics
You don’t need to master Git to contribute — just keep your branch up to date and make your changes visible to the team in a clean and organized way.