What You Need to Know First
Repository (Repo): A folder that Git tracks. It contains your project files and entire version history.
Branch: A parallel version of your code. Think of it like making a copy of your project to work on without affecting the main version.
Main/Master Branch: The primary branch. This is usually your production-ready code. It should always be stable.
Pull Request (PR): A way to propose changes. It says “I’d like to merge my branch into the main branch” and lets others review your code first.
Step 1: Get the Repository
First, you need to get the project code onto your computer.
git clone https://github.com/username/project-name.git cd project-name
This downloads the entire project to your computer. Now you’re ready to work.
Step 2: Update Your Local Code
Before starting anything new, always get the latest version of the main branch:
git checkout main git pull origin main
git checkout main = Switch to the main branch git pull origin main = Download the latest changes from the remote server
Step 3: Create a Feature Branch
Never work directly on the main branch. Create a new branch for your feature or bugfix:
git checkout -b feature/my-awesome-feature
Good branch naming conventions:
- feature/user-loginfor new features
- bugfix/fix-login-errorfor bug fixes
- hotfix/critical-crashfor urgent fixes
Step 4: Make Your Changes
Now edit files, write code, and do your work. You can use your text editor or IDE normally.
Step 5: Check Your Changes
Before committing, see what you’ve changed:
git status
This shows which files you’ve modified. Review them to make sure everything looks right.
Step 6: Stage Your Changes
Staging means marking specific changes to be included in your next commit:
git add .
The . means “add all my changes”. You can also add specific files:
git add filename.txt
Check what’s staged:
git status
Step 7: Commit Your Changes
A commit is like a save point. Write a clear message describing what you did:
git commit -m "Add user authentication feature"
Good commit messages:
- Start with a verb: “Add”, “Fix”, “Update”, “Remove”
- Be descriptive but concise
- Explain WHAT you did and WHY (if the why is unclear)
Step 8: Push Your Branch to GitHub
Upload your branch to the remote server (GitHub):
git push origin feature/my-awesome-feature
origin = the remote server (usually GitHub)
Step 9: Create a Pull Request
Go to your GitHub repository in your browser. You’ll usually see a prompt to create a PR. Click it. If not:
- Click the “Pull requests” tab
- Click “New pull request”
- Select:
- Base branch: main(where you want to merge into)
- Compare branch: feature/my-awesome-feature(your branch)
 
- Base branch: 
Add a title and description explaining your changes:
Title: Add user authentication Description: - Implemented login page - Added password hashing - Created session management - Fixes #42 (reference related issues)
Click “Create Pull Request”
Step 10: Code Review
Your team reviews your code. They might:
- Ask questions
- Request changes
- Approve it
If they request changes:
# Make the requested edits in your files git add . git commit -m "Address code review feedback" git push origin feature/my-awesome-feature
Your PR automatically updates. You don’t need to create a new one.
Step 11: Merge Your PR
Once approved, merge your branch into main:
- Click “Merge pull request” on GitHub, or
- Use the command line:
git checkout main git pull origin main git merge feature/my-awesome-feature git push origin main
Step 12: Delete Your Branch
After merging, delete the feature branch (you don’t need it anymore):
git branch -d feature/my-awesome-feature git push origin --delete feature/my-awesome-feature
Step 13: Feature Releases
When you’re ready to release a version:
1. Create a Release Branch
git checkout main git pull origin main git checkout -b release/v1.0.0
2. Update Version Numbers
Update your version in:
- package.json(for Node.js projects)
- version.py(for Python)
- Any other version files
git add . git commit -m "Bump version to 1.0.0" git push origin release/v1.0.0
3. Create a PR for the Release
Create a PR from release/v1.0.0 to main. This gives everyone a chance to review.
4. Merge to Main
Once approved, merge to main (this becomes your official release).
5. Tag the Release
git checkout main git pull origin main git tag -a v1.0.0 -m "Release version 1.0.0" git push origin v1.0.0
This marks the exact point in your code history for this release.
6. Merge Back to Development
If you have a develop branch, merge the release back:
git checkout develop git pull origin develop git merge main git push origin develop
Quick Reference: Complete Workflow
# 1. Update main branch git checkout main git pull origin main # 2. Create feature branch git checkout -b feature/my-feature # 3. Make changes, then: git status git add . git commit -m "Describe your changes" # 4. Push to GitHub git push origin feature/my-feature # 5. Create PR on GitHub (in browser) # 6. Once approved, merge (can be done on GitHub or CLI): git checkout main git pull origin main git merge feature/my-feature git push origin main # 7. Clean up git branch -d feature/my-feature git push origin --delete feature/my-feature
Common Commands Cheat Sheet
| Command | What It Does | 
|---|---|
| git status | See what’s changed | 
| git checkout -b branch-name | Create and switch to a new branch | 
| git checkout branch-name | Switch to a branch | 
| git add . | Stage all changes | 
| git commit -m "message" | Save changes with a message | 
| git push origin branch-name | Upload branch to GitHub | 
| git pull origin branch-name | Download latest changes | 
| git merge branch-name | Combine another branch into current branch | 
| git branch | List all branches | 
| git branch -d branch-name | Delete a branch | 
| git log | See commit history | 
Tips for Success
- Always create a new branch for each feature or bugfix
- Pull before you work to avoid conflicts
- Commit often with clear messages
- Test locally before pushing
- Review your own code before requesting reviews
- Keep commits focused – one feature per branch, not five
- Never force push to main (git push --force)
- Be kind in code reviews – we’re all learning
Troubleshooting
“I committed to main by accident”
git reset --soft HEAD~1 git checkout -b feature/my-feature git commit -m "My changes"
“I made a typo in my commit message”
git commit --amend -m "New message" git push origin branch-name --force-with-lease
“My branch is out of date”
git fetch origin git rebase origin/main
“I have merge conflicts” Open the conflicted files in your editor, manually resolve them, then:
git add . git commit -m "Resolve merge conflicts" git push origin branch-name