0% found this document useful (0 votes)
3 views27 pages

Git Learningnotes

The document is a comprehensive guide for new team members on using Git and GitHub, covering essential commands, workflows, and best practices. It explains Git fundamentals, branching strategies, merging, conflict resolution, and GitHub-specific features like pull requests and actions. The guide aims to equip new developers with the necessary skills to effectively collaborate and manage code in a team environment.

Uploaded by

sudarsettaiyan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views27 pages

Git Learningnotes

The document is a comprehensive guide for new team members on using Git and GitHub, covering essential commands, workflows, and best practices. It explains Git fundamentals, branching strategies, merging, conflict resolution, and GitHub-specific features like pull requests and actions. The guide aims to equip new developers with the necessary skills to effectively collaborate and manage code in a team environment.

Uploaded by

sudarsettaiyan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Git & GitHub Complete Guide | For New Team Members

Git & GitHub


Complete Field Guide for New Team Members
Commands · Scenarios · GitHub Actions · Best Practices

What You Will Learn

• Git fundamentals — how version control actually works


• Every essential command explained with real-world scenarios
• Branching strategies teams use day-to-day
• Merging, rebasing, and resolving conflicts like a pro
• Remote repositories and collaboration workflows
• GitHub-specific features — PRs, Issues, forks, and more
• GitHub Actions — CI/CD pipelines from zero to production
• Tips, tricks, and mistakes to avoid on your first week

Page 1 of 27
Git & GitHub Complete Guide | For New Team Members

1. What is Git? (And Why Should You Care?)


Git is a distributed version control system. Every developer on your team has a full copy of the
project history on their own machine. You don't need internet access to work — only when
syncing with the team's shared remote.

💡 The Core Mental Model


Think of Git as a timeline of snapshots (called commits). You can travel back in time, branch off into
parallel timelines, and merge those timelines back together. GitHub is just a website that hosts these
timelines in the cloud so your team can collaborate.

Key Concepts Explained Simply


Command What it does
Repository (repo) The folder where Git tracks everything — your code + the full history
Commit A saved snapshot of your project at a point in time
Branch A parallel version of the project — safe to experiment without breaking
main
Remote A copy of the repo hosted online (usually on GitHub)
Clone Downloading a remote repo to your local machine
Push Uploading your local commits to the remote
Pull Downloading new commits from the remote to your local
Merge Combining changes from two branches
Pull Request A request on GitHub to review and merge your branch

Page 2 of 27
Git & GitHub Complete Guide | For New Team Members

2. First-Time Setup
Before you write a single line of code, tell Git who you are. This identity gets stamped on every
commit you make.

Configure Your Identity


# Set your name (shown in commit history)
git config --global [Link] "Your Name"

# Set your email (should match your GitHub account)


git config --global [Link] "you@[Link]"

# Set VS Code as your default editor


git config --global [Link] "code --wait"

# Enable colored output (very useful!)


git config --global [Link] auto

# View all your settings


git config --list

📌 Scenario: You just joined the company and need to set up Git on your laptop.

Command git config --global [Link] "Arjun Kumar"

Result Every commit you make will now be tagged with your name and email — no
more mystery commits!

Connect to GitHub with SSH (Recommended)


SSH keys let you push/pull without typing your password every time. Most companies require
this.

# Generate an SSH key


ssh-keygen -t ed25519 -C "you@[Link]"

# Copy the public key to your clipboard (Mac)


pbcopy < ~/.ssh/id_ed25519.pub

# Copy the public key to your clipboard (Linux)


cat ~/.ssh/id_ed25519.pub

# Then go to GitHub → Settings → SSH Keys → New SSH Key → paste

Page 3 of 27
Git & GitHub Complete Guide | For New Team Members

# Test the connection


ssh -T git@[Link]
# You should see: Hi username! You have successfully authenticated.

Page 4 of 27
Git & GitHub Complete Guide | For New Team Members

3. Starting With a Repository

Scenario A — Joining an Existing Project (Most Common)


📌 Scenario: Your manager sends you the GitHub repo link for the project you'll be working on.

Command git clone git@[Link]:company/[Link]

Result Creates a folder called 'project' on your machine with the full history. You're
ready to work!

# Clone into a specific folder name


git clone git@[Link]:company/[Link] my-folder

# Clone and immediately go into the folder


git clone git@[Link]:company/[Link] && cd project

Scenario B — Starting a Brand New Project


📌 Scenario: You're building a new microservice from scratch and need to put it under version
control.

Command git init

Result Creates a hidden .git folder in your current directory. Git is now tracking this
project.

# Start a new repo in the current folder


git init

# Start a new repo in a new folder


git init my-new-project

# Link it to an empty GitHub repo you created


git remote add origin git@[Link]:yourname/[Link]
git branch -M main
git push -u origin main

Understanding Remote Connections


# See what remotes are connected
git remote -v

Page 5 of 27
Git & GitHub Complete Guide | For New Team Members

# Add a remote
git remote add origin git@[Link]:company/[Link]

# Change the remote URL (e.g., after a repo is renamed)


git remote set-url origin git@[Link]:company/[Link]

# Remove a remote
git remote remove origin

Page 6 of 27
Git & GitHub Complete Guide | For New Team Members

4. The Daily Git Workflow


This is what you'll do every single day. Understand these commands deeply — they're your
bread and butter.

🔄 The Three-Stage Model


Git has 3 areas: (1) Working Directory — where you edit files. (2) Staging Area (Index) — where you
prepare your next commit. (3) Repository — where commits are permanently saved. Think of staging
as packing a box: you choose what goes in, then seal it with a commit.

Checking What's Going On


# See the status of your files (run this constantly!)
git status

# See what exactly changed (line by line)


git diff

# See diff of staged files


git diff --staged

# See recent commits


git log

# See commits as a compact one-liner


git log --oneline

# See commits as a visual graph (great for branches)


git log --oneline --graph --all

📌 Scenario: You've been coding for an hour. You want to know what files you changed before
committing.

Command git status

Result Shows red files (not staged) and green files (staged). Gives you full clarity before
you commit.

Staging and Committing


# Stage a specific file
git add [Link]

Page 7 of 27
Git & GitHub Complete Guide | For New Team Members

# Stage multiple files


git add [Link] [Link]

# Stage an entire folder


git add src/

# Stage ALL changed files (use carefully!)


git add .

# Commit staged files with a message


git commit -m "feat: add user login validation"

# Stage all tracked files AND commit in one step


git commit -am "fix: correct typo in API response"

# Edit the last commit message (before pushing!)


git commit --amend -m "fix: correct typo in API response message"

📌 Scenario: You fixed a bug in [Link] and updated the README. You want to make separate
commits for each.

Command git add [Link] git commit -m "fix: resolve token expiry
bug" git add [Link] git commit -m "docs: update auth
setup instructions"

Result Two clean, focused commits — each one tells a clear story. Future-you will thank
present-you.

✍ Writing Good Commit Messages


Format: type: short description (50 chars max). Types: feat (new feature), fix (bug fix), docs
(documentation), refactor (code cleanup), test (adding tests), chore (maintenance). Example: 'feat:
add email verification on signup'. A good commit message explains WHY, not just what.

Undoing Mistakes
# Unstage a file (keep your changes, just remove from staging)
git restore --staged [Link]

# Discard changes in a file (WARNING: this cannot be undone!)


git restore [Link]

# Undo the last commit but KEEP the changes as unstaged


git reset HEAD~1

# Undo the last commit and KEEP changes staged

Page 8 of 27
Git & GitHub Complete Guide | For New Team Members

git reset --soft HEAD~1

# Nuclear option: undo commit AND discard all changes


git reset --hard HEAD~1

# Safely undo a commit by creating a new 'reversal' commit


git revert abc1234

📌 Scenario: You committed a file with a hardcoded password. You haven't pushed yet. You need to
undo it FAST.

Command git reset --soft HEAD~1

Result Your commit is undone, but your changes are still staged. Remove the sensitive
file, fix it, then re-commit safely.

⚠ Golden Rule
Never use 'git reset --hard' on commits that have already been pushed to a shared remote. It rewrites
history and will cause problems for your teammates. Use 'git revert' instead — it adds a new commit
that undoes the change, keeping history intact.

Page 9 of 27
Git & GitHub Complete Guide | For New Team Members

5. Branching — Working in Parallel


Branches are one of Git's killer features. They let you work on a feature or fix without touching
the main codebase until you're ready. Every new piece of work = new branch. This is non-
negotiable in professional teams.

Branch Commands
# List all local branches
git branch

# List all branches including remote


git branch -a

# Create a new branch


git branch feature/user-auth

# Switch to a branch
git checkout feature/user-auth

# Create AND switch in one command (modern way)


git switch -c feature/user-auth

# Rename the current branch


git branch -m new-name

# Delete a branch (after merging)


git branch -d feature/user-auth

# Force delete (even if not merged — use carefully!)


git branch -D feature/user-auth

📌 Scenario: Your team uses a naming convention: feature/, fix/, hotfix/. You need to build a user
dashboard.

Command git switch -c feature/user-dashboard

Result You're now on a fresh branch. All commits you make here stay isolated until
you're ready to merge.

Typical Branching Workflow


# 1. Start from a fresh main branch
git switch main

Page 10 of 27
Git & GitHub Complete Guide | For New Team Members

git pull origin main

# 2. Create your feature branch


git switch -c feature/payment-integration

# 3. Do your work, stage, commit


git add .
git commit -m "feat: integrate Stripe payment gateway"

# 4. Push branch to GitHub


git push -u origin feature/payment-integration

# 5. Open a Pull Request on GitHub → get reviewed → merge

# 6. After merge, clean up


git switch main
git pull origin main
git branch -d feature/payment-integration

Keeping Your Branch Up to Date


📌 Scenario: You've been on your feature branch for 3 days. main has moved on. You need to sync
up before creating your PR.

Command git fetch origin git rebase origin/main

Result Your commits are replayed on top of the latest main. Your PR will have no
conflicts.

# Method 1: Merge main into your branch (keeps history, creates merge commit)
git merge main

# Method 2: Rebase (rewrites your commits on top of main — cleaner history)


git rebase main

# If rebase has conflicts, fix them, then:


git add .
git rebase --continue

# To abort a rebase if things go wrong:


git rebase --abort

Page 11 of 27
Git & GitHub Complete Guide | For New Team Members

6. Merging and Resolving Conflicts

How Merging Works


When you merge two branches, Git compares their histories and combines the changes. If two
people changed the same lines of the same file, Git doesn't know which version to keep —
that's a conflict, and you have to resolve it manually.

# Merge a branch into your current branch


git merge feature/user-auth

# Merge but always create a merge commit (even if fast-forward is possible)


git merge --no-ff feature/user-auth

# Abort a merge if conflicts are too complex


git merge --abort

Resolving Conflicts Step by Step


📌 Scenario: You try to merge your branch and Git says 'CONFLICT (content): Merge conflict in
[Link]'.

Command git status → open the file → fix → git add → git
commit

Result Git marks the conflicting file. You edit it, choose what to keep, stage it, and
complete the merge.

# Step 1: See which files have conflicts


git status

# Step 2: Open the conflicted file — it looks like this:


# <<<<<<< HEAD
# const greeting = 'Hello'; ← your version
# =======
# const greeting = 'Hi there!'; ← their version
# >>>>>>> feature/ui-update

# Step 3: Edit the file to keep what you want, delete the markers
# const greeting = 'Hello'; ← decide and clean up

# Step 4: Mark as resolved


git add [Link]

# Step 5: Complete the merge

Page 12 of 27
Git & GitHub Complete Guide | For New Team Members

git commit -m "merge: resolve greeting conflict in [Link]"

🛠 Pro Tip: Use a Visual Merge Tool


Run 'git mergetool' to open a visual diff tool (VS Code, IntelliJ, vimdiff). It shows three panes: your
version, their version, and the combined result. Much easier than editing raw conflict markers in a
text file.

Page 13 of 27
Git & GitHub Complete Guide | For New Team Members

7. Working With Remote Repositories

Push, Pull, and Fetch


# Push your current branch to remote
git push origin feature/my-branch

# Push and set upstream tracking (do this on first push)


git push -u origin feature/my-branch

# After setting upstream, you can just type:


git push

# Download new commits from remote (does NOT merge into your branch)
git fetch origin

# Download AND merge into your current branch (fetch + merge)


git pull

# Pull using rebase instead of merge (cleaner history)


git pull --rebase

📌 Scenario: You start your workday. Your colleague pushed 3 commits to main overnight. You
need the latest code before you start.

Command git switch main && git pull origin main

Result Your local main is now up to date. Create a new branch from here to start today's
work.

Stashing — Saving Work Without Committing


📌 Scenario: You're midway through a feature. Your manager calls and asks you to fix an urgent
bug on main. You can't commit half-done work.

Command git stash

Result Your work is temporarily saved. Switch to main, fix the bug, come back and
restore your work.

# Stash your current changes


git stash

# Stash with a descriptive name


git stash push -m "half-done user dashboard"

Page 14 of 27
Git & GitHub Complete Guide | For New Team Members

# List all stashes


git stash list

# Restore the most recent stash


git stash pop

# Restore a specific stash


git stash apply stash@{2}

# Delete a stash
git stash drop stash@{0}

# Delete all stashes


git stash clear

Tags — Marking Releases


# Create a lightweight tag
git tag v1.0.0

# Create an annotated tag (preferred for releases)


git tag -a v1.0.0 -m "First stable release"

# List all tags


git tag

# Push tags to remote


git push origin --tags

# Delete a tag
git tag -d v1.0.0

Page 15 of 27
Git & GitHub Complete Guide | For New Team Members

8. GitHub-Specific Features

Pull Requests (PRs) — The Heart of Collaboration


A Pull Request is how you propose your changes to the team. It's a space for code review,
discussion, and approval before anything hits main. Opening a good PR is a professional skill in
itself.

The Pull Request Workflow


# 1. Create your branch and do your work locally
git switch -c feature/add-search
# ... write code ...
git commit -m "feat: implement product search with filters"

# 2. Push your branch to GitHub


git push -u origin feature/add-search

# 3. Go to GitHub — you'll see a banner offering to open a PR


# Fill in: title, description, reviewers, labels, milestone

# 4. Address review comments — just push more commits to same branch


git commit -m "fix: address PR feedback on search validation"
git push

# 5. Once approved, merge via GitHub UI


# (or if you have permission, from command line)
git switch main
git merge feature/add-search
git push

📝 A Great PR Description Includes


What changed (a concise summary). Why it changed (the problem being solved). How to test it
(steps a reviewer can follow). Screenshots if there are UI changes. Link to the issue it resolves (use
'Closes #42' to auto-close the issue on merge).

Forking — Contributing to Public Repos


📌 Scenario: You want to contribute to an open-source library. You don't have write access to the
repo.

Command Fork on GitHub → git clone YOUR fork → make changes → PR to


original

Page 16 of 27
Git & GitHub Complete Guide | For New Team Members

Result A fork is your own copy of the repo on GitHub. You commit to your fork, then
open a PR to the original.

# After forking on GitHub, clone your fork


git clone git@[Link]:YOUR-USERNAME/[Link]

# Add the original repo as 'upstream' remote


git remote add upstream git@[Link]:original-owner/[Link]

# Keep your fork up to date


git fetch upstream
git merge upstream/main

# Push to your fork, then open a PR from your fork to original


git push origin feature/my-contribution

Issues, Labels, and Milestones


Command What it does
Issues Track bugs, features, and tasks. Every PR should link to an issue.
Labels Categorize issues: bug, enhancement, help wanted, good first issue
Milestones Group issues into a release or sprint goal
Assignees Who is responsible for resolving the issue
Closes #42 Put this in a commit message or PR description to auto-close issue #42
on merge
Projects Kanban-style boards to track issue status across the team

GitHub Shortcuts You Must Know


Command What it does
Closes #42 Auto-closes issue 42 when the PR is merged (put in PR description)
@teammate Notify a specific person in a comment
#branch-name Reference a branch in a comment
code blocks Use triple backticks in comments for formatted code
.github/ Special folder: put PR templates, issue templates, workflows here
gh CLI GitHub's command-line tool — manage PRs and issues from terminal

Page 17 of 27
Git & GitHub Complete Guide | For New Team Members

9. .gitignore — What NOT to Commit


The .gitignore file tells Git which files and folders to never track. This is critical — you never
want to commit node_modules, secret keys, build artifacts, or editor config files.

# Common .gitignore entries

# Dependencies
node_modules/
vendor/

# Environment and secrets


.env
.[Link]
*.key
*.pem

# Build artifacts
dist/
build/
*.pyc
__pycache__/

# Editor files
.vscode/
.idea/
*.swp

# OS files
.DS_Store
[Link]

📌 Scenario: You accidentally committed your .env file with real database credentials. The commit
isn't pushed yet.

Command git rm --cached .env && echo '.env' >> .gitignore && git
commit -m 'chore: remove .env from tracking'

Result The file is removed from Git tracking but stays on your disk. Add it to .gitignore so
it never happens again.

🔒 If You Pushed Secrets to GitHub


Immediately rotate (change) all exposed credentials — assume they are already compromised. Then
use 'git filter-branch' or BFG Repo Cleaner to remove the secret from history, and force-push.
Contact your security team — GitHub also has secret scanning that will alert you automatically.

Page 18 of 27
Git & GitHub Complete Guide | For New Team Members

10. Advanced Commands You'll Need

Cherry Pick — Grab a Specific Commit


📌 Scenario: A colleague fixed a critical bug on their feature branch. The fix is in one commit. You
need that fix on main NOW, without merging their whole branch.

Command git cherry-pick abc1234

Result That single commit is applied to your current branch. Perfect for hotfixes and
emergency patches.

# Apply a specific commit to current branch


git cherry-pick abc1234

# Cherry-pick a range of commits


git cherry-pick abc1234^..def5678

# Cherry-pick without auto-committing (to review first)


git cherry-pick -n abc1234

Interactive Rebase — Rewrite History


📌 Scenario: You have 8 messy WIP commits on your branch before opening the PR. You want to
clean them up into 2 clean commits.

Command git rebase -i HEAD~8

Result An editor opens showing your last 8 commits. Change 'pick' to 'squash' or 'fixup'
to combine them. 'reword' to rename. 'drop' to delete.

# Interactive rebase on last N commits


git rebase -i HEAD~5

# In the editor, commands per commit:


# pick = keep as-is
# reword = keep but rename the commit message
# squash = merge into previous commit (keep both messages)
# fixup = merge into previous commit (discard this message)
# drop = delete this commit entirely

Bisect — Find Which Commit Broke Something

Page 19 of 27
Git & GitHub Complete Guide | For New Team Members

📌 Scenario: The app worked last week. It doesn't now. There are 200 commits in between. You
need to find the exact bad commit.

Command git bisect start → git bisect bad → git bisect good v1.2 →
test → repeat

Result Git automatically binary-searches through commits, cutting the range in half each
time. Finds the culprit in ~8 steps no matter how many commits there are.

# Start bisect
git bisect start

# Tell Git the current state is bad


git bisect bad

# Tell Git a known good commit/tag


git bisect good v1.2.0

# Git checks out a middle commit — test your app


# If it works:
git bisect good
# If it's broken:
git bisect bad

# Git will eventually say: 'abc1234 is the first bad commit'

# End the bisect session


git bisect reset

Reflog — The Ultimate Undo


📌 Scenario: You ran 'git reset --hard' and lost some commits. You think everything is gone.

Command git reflog

Result Git keeps a log of EVERY HEAD position for 90 days. Find your lost commit's
hash and 'git checkout' it to recover.

# See full history of HEAD movements


git reflog

# Recover a lost commit


git checkout abc1234

# Or bring it back as a new branch


git checkout -b recovery/my-lost-work abc1234

Page 20 of 27
Git & GitHub Complete Guide | For New Team Members

Page 21 of 27
Git & GitHub Complete Guide | For New Team Members

11. GitHub Actions — Automate Everything


GitHub Actions is GitHub's built-in CI/CD (Continuous Integration / Continuous Deployment)
system. It lets you automate tasks — running tests, linting code, building apps, deploying to
servers — triggered by events in your repository.

🤖 What Can GitHub Actions Do?


Run your test suite on every PR. Automatically deploy to AWS/Vercel/Heroku when you merge to
main. Lint code and post a comment if it fails. Send a Slack notification when a release is published.
Automatically close stale issues. Literally anything that can be scripted.

Core Concepts
Command What it does
Workflow A YAML file in .github/workflows/ that defines automation
Event/Trigger What causes the workflow to run (push, pull_request, schedule, etc.)
Job A group of steps that run on the same machine
Step A single task: run a command or use a pre-built Action
Action A reusable, community-built step from the GitHub Marketplace
Runner The virtual machine that executes your job (ubuntu-latest, windows-latest)
Secrets Encrypted variables for API keys and passwords
Artifacts Files saved from a workflow (test reports, build outputs)

Your First Workflow — Run Tests on Every PR


# File: .github/workflows/[Link]

name: CI Pipeline

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:

Page 22 of 27
Git & GitHub Complete Guide | For New Team Members

- name: Checkout code


uses: actions/checkout@v4

- name: Set up [Link]


uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies


run: npm ci

- name: Run linter


run: npm run lint

- name: Run tests


run: npm test

- name: Upload coverage report


uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/

Deploy to Production on Merge to Main


# File: .github/workflows/[Link]

name: Deploy to Production

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v4

- name: Set up [Link]


uses: actions/setup-node@v4
with:
node-version: '20'

Page 23 of 27
Git & GitHub Complete Guide | For New Team Members

- name: Install and build


run: |
npm ci
npm run build

- name: Deploy to AWS


env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync ./dist s3://my-bucket --delete
aws cloudfront create-invalidation --distribution-id
${{ secrets.CF_DIST_ID }} --paths '/*'

Using Secrets Safely


📌 Scenario: Your deployment workflow needs an API key, but you can't hardcode it in the YAML
file — it's in a public repo!

Command GitHub Settings → Secrets and variables → Actions → New


repository secret

Result Store the key as a secret named MY_API_KEY. Access it in the workflow as
${{ secrets.MY_API_KEY }}. It's masked in all logs.

Scheduled Workflow — Run Every Night


# File: .github/workflows/[Link]

name: Nightly Database Backup

on:
schedule:
- cron: '0 2 * * *' # 2:00 AM UTC every day
workflow_dispatch: # Also allow manual trigger

jobs:
backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run backup script


env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: ./scripts/[Link]

Page 24 of 27
Git & GitHub Complete Guide | For New Team Members

Matrix Builds — Test on Multiple Environments


# Test your code on Node 18, 20, and 22 simultaneously

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ [Link]-version }}
- run: npm ci && npm test

Workflow Tips
• Always pin action versions: use @v4, not @latest — it prevents unexpected breaking
changes
• Use 'npm ci' instead of 'npm install' in CI — it's faster and more reliable
• Cache dependencies: use 'cache: npm' in setup-node to dramatically speed up
workflows
• Add branch protection rules on GitHub to require CI to pass before merging a PR
• Use 'workflow_dispatch' to add a manual trigger button — great for deployments
• Check the GitHub Marketplace for thousands of pre-built Actions (Docker, Terraform,
Slack, etc.)

Page 25 of 27
Git & GitHub Complete Guide | For New Team Members

12. Quick Reference Cheat Sheet

Essential Commands at a Glance


Command What it does
git clone <url> Download a remote repo to your machine
git status See what's changed (run this constantly)
git add <file> Stage a file for the next commit
git add . Stage ALL changed files
git commit -m "msg" Save staged files as a commit
git push Upload commits to remote
git pull Download and merge remote commits
git fetch Download remote commits (without merging)
git switch -c <name> Create and switch to a new branch
git switch <name> Switch to an existing branch
git branch -d <name> Delete a local branch
git merge <branch> Merge a branch into your current branch
git rebase main Replay your commits on top of main
git stash Temporarily save uncommitted work
git stash pop Restore the most recent stash
git log --oneline See compact commit history
git diff See unstaged line-by-line changes
git reset HEAD~1 Undo last commit (keep changes)
git revert <hash> Safely undo a commit by adding a reversal commit
git cherry-pick <hash> Apply one specific commit to current branch
git reflog See full history of HEAD — ultimate undo tool
git tag -a v1.0 -m "" Create an annotated release tag

Your First Week Checklist


1. Configure git config --global [Link] and [Link]
2. Set up SSH keys and connect to GitHub
3. Clone the main project repository
4. Ask your team about their branching strategy (Git Flow, trunk-based, etc.)
5. Read the .github/workflows/ folder to understand what CI runs
6. Create your first branch and open your first PR — even a tiny change counts
7. Run git log --oneline --graph --all to visualize the project history

Page 26 of 27
Git & GitHub Complete Guide | For New Team Members

🚀 You've Got This!


The best way to learn Git is to use it every day. Make small commits, write clear messages, and don't
be afraid to ask teammates about their workflow. Everyone remembers being new to Git — your
team will be happy to help. Welcome aboard!

Page 27 of 27

You might also like