Skip to content
/ git Public

Master Git step-by-step from beginner to advanced. Check off tasks as you complete them!

Notifications You must be signed in to change notification settings

thalsi/git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ… Git Mastery Checklist (Beginner β†’ Advanced)


🟒 Beginner

🧩 1. Setup & Configuration

  • Install Git
  • git config --global user.name "Your Name"
  • git config --global user.email "[email protected]"
  • Set default branch: init.defaultBranch main
  • Set default editor: VS Code, Vim, etc.
  • Enable color UI
  • View current config: git config --list
  • View current config: git config --list --global

πŸ“ 2. Git Basics

  • git init - Initialize a new Git repository.
  • git status - Check the status of files β€” modified, staged, untracked.
  • git add / git add . - Stage file(s) to be committed.
  • git commit -m "message" - Commit staged changes with a message.
  • git log / git log --oneline - View commit history (detailed or short).
  • git diff - See what’s changed before staging.
  • git show - Show the details of a specific commit.
  • Use .gitignore - Ignore files you don’t want Git to track (e.g., node_modules/, env, dist).

🌿 3. Branching & Merging

  1. Branching
  • git branch – List all local branches
  • git branch <name> – Create a new branch
  • git switch <branch> – Switch to a branch (newer)
  • git checkout <branch> – Switch to a branch (older method)
  • git checkout -b <name> – Create and switch to a new branch
  • git branch -d <name> – Delete a local branch (safe)
  • git branch -D <name> – Delete a local branch (force)
  • git branch -m <new> – Rename current branch
  • git branch -vv – Show branches with last commit info
  • git push origin <branch> – Push branch to remote
  • git push --set-upstream origin <branch> – Link local branch to remote
  • git fetch --all – Fetches all branches from all remotes (usually just origin) but does NOT merge or checkout anything.
  • git fetch -p – It tells Git to remove (prune) any remote-tracking branches that no longer exist on the remote.
  1. Merging Git Merge is used to combine changes from one branch into another. Usually, you merge a feature branch into a main/stable branch.

πŸ“¦ Merge Types in Git

Merge Type Description
🟒 Fast-forward Merge Simple move of the pointer if there’s no diverging history.
🟑 Recursive Merge The default merge strategy when branches have diverged.
πŸ”΅ No Fast-forward Merge (--no-ff) Always creates a merge commit to preserve history.
πŸ”΄ Manual Merge Required when there’s a conflict.

✳️ Common Merge Commands

  • git merge <branch> – Merge the given branch into the current branch
  • git merge --no-ff <branch> – Force a merge commit even on fast-forward
  • git merge --squash <branch> – Merge and squash into a single commit
  • git merge --abort – Abort a merge in progress
  • git merge --continue – Continue merge after resolving conflicts

🌐 4. Remote Repositories

  • git remote add origin
  • git push -u origin main
  • git push / git pull
  • git clone
  • git remote -v
  • git push --set-upstream origin
  • git branch -vv
  • git branch --set-upstream-to

🧼 5. Undo & History Fixing

  • git reset --soft / --mixed / --hard
  • git restore
  • git restore .
  • git restore --staged
  • git commit --amend
  • git reflog
  • git clean -fd
  • git reset --merge (undo merge)

🟑 Intermediate

πŸ” 6. Rebase & Cherry-Pick

πŸ’ Cherry-pick

  • git cherry-pick <commit> – Apply specific commit from another branch
  • git cherry-pick commit1 commit2 commit3 – You can also cherry-pick multiple commits
  • git cherry-pick A^..B – even a range of commits

Rebase

git rebase moves or reapplies commits from one branch on top of another. It rewrites history to create a cleaner, linear commit history.

🎯 When to Use Rebase βœ… Clean up history βœ… Avoid extra merge commits βœ… Keep project history linear βœ… Re-apply your local feature branch on top of main

  • git rebase <branch> – Reapply current branch commits on top of <branch>
  • git rebase -i <branch> – Interactive rebase: squash, reword, drop commits
  • git rebase -i HEAD~n – Interactively edit the last n commits
  • git rebase --autosquash – Auto-squash commits marked with fixup! or squash!
  • git rebase --continue – Continue rebase after resolving conflicts
  • git rebase --abort – Abort the rebase and return to the previous state
  • git rebase --skip – Skip the current conflicting commit during rebase
  • git pull --rebase – Pull latest changes using rebase instead of merge
  • git status – Check status during rebase (conflicts, progress)
  • git log – Review commit history before/after rebase
  • Resolve conflicts manually – Fix file conflicts and mark as resolved
Command git rebase -i <branch> Meaning
pick Keep commit as-is
reword Change commit message
edit Pause to change content
squash Combine with previous commit (keep both messages)
fixup Combine with previous, discard this message
drop Delete this commit

🏷️ 7. Tags & Releases

  • git tag
  • git tag -a -m "message"
  • git show
  • git push origin
  • git push --tags

πŸ“¦ 8. Stashing & Cleaning

  • git stash – Stash tracked modified files
  • git stash -u – Stash tracked + untracked files (not ignored)
  • git stash -a – Stash all (tracked + untracked + ignored)
  • git stash list – View list of stashes
  • git stash show – Show summary of latest stash
  • git stash show -p – Show patch/diff of latest stash
  • git stash pop – Apply stash and delete it
  • git stash apply – Apply stash but keep it
  • git stash drop – Delete latest stash
  • git stash clear – Delete all stashes
  • git stash push -m "message" – Stash with custom message

πŸ” 9. Git Inspection Tools

  • git log with formatting
  • git diff --cached
  • git blame
  • git describe
  • git shortlog
  • git shortlog -sn

πŸ‘₯ 10. Team Collaboration

  • Use Pull Requests / Merge Requests
  • Feature branch workflow
  • Gitflow workflow
  • Code review & approvals
  • Protected branches
  • Squash commits before merge

πŸ› οΈ 11. Git Hooks & Automation

  • Setup Husky for hooks
  • Use pre-commit, commit-msg, post-merge
  • Use lint-staged for auto formatting
  • Create .husky/ scripts
  • Use git commit --no-verify (with caution)

πŸ—‚οΈ 12. Aliases & Tools


βš™οΈ 13. Git Internals (Advanced)

  • Understand .git/ structure
  • Git Object Types: blob, tree, commit, tag
  • Learn about HEAD, refs, index
  • Learn SHA-1 and commit IDs

🐞 14. Debugging & Recovery

  • Conflict resolution
  • Detached HEAD fixes
  • Use reflog to recover lost commits
  • git bisect start / bad / good (binary search debugging)

πŸš€ 15. CI/CD Integration

  • Setup GitHub Actions or GitLab CI
  • Configure .github/workflows/
  • Use CI for test/lint/build
  • Auto deployment with git tags
  • Test GitHub Actions locally with act

✏️ 16. Commit Message Standards

  • Use Conventional Commits (feat:, fix:, chore:, etc.)
  • Install commitlint
  • Use Commitizen (cz) for commits
  • Validate commits with hooks

πŸ“ 17. Monorepo & Submodules

  • git submodule add
  • git submodule update --init
  • Learn subtrees (optional)
  • Use Nx or Lerna for monorepo

πŸ”΄ Advanced

πŸ” 18. Security & Best Practices

  • Use .env files and gitignore
  • Install git-secrets
  • GPG sign commits
  • Enable 2FA on GitHub
  • Remove secrets from history (BFG or git filter-branch)

🏒 19. Git in Teams

  • Simulate team workflows
  • Use pair programming tools (git-duet)
  • Create/merge PRs
  • Trunk-based development
  • Fork vs shared branch model

🌍 20. Git Hosting Platforms

  • GitHub
  • GitLab
  • Bitbucket
  • Azure Repos

πŸ§ͺ 21. Extra Git Tools

  • git worktree (multiple working dirs)
  • git archive (create zip/tar)
  • git format-patch / git apply / git am (email-based flow)
  • git fame (contribution analytics)
  • git LFS for large files

πŸ“š 22. Learning Resources


✍️ BONUS: Aliases to Save Time

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.lg "log --oneline --graph --all"

🧠 23. Advanced History & Commit Management

  • git commit --fixup and git rebase --autosquash
  • git notes – add metadata/comments to commits
  • git revert -n (stage multiple reverts)
  • Understand orphan branches: git checkout --orphan newbranch

πŸ—ƒοΈ 24. Repo Size & History Optimization

  • git gc (garbage collection to optimize repo)
  • git repack (compress objects)
  • git verify-pack / git count-objects -v (inspect storage)
  • Use BFG Repo-Cleaner for large repos

πŸ›‘οΈ 25. Git & Compliance

  • Audit history for secrets (truffleHog, gitleaks)
  • Enforce signed commits via branch protection
  • Enforce linear history in main branch
  • Use branch naming conventions and enforce them

⚑ 26. Git Performance & Scaling

  • Use git sparse-checkout (large monorepos)
  • Partial clone (--filter=blob:none) for huge projects
  • Split large repos with git subtree split

πŸ”§ 27. Custom Git Workflows

  • Setup custom merge drivers
  • Setup .mailmap to unify commit authors
  • Use .git/info/exclude for local-only ignores
  • Custom diff drivers (e.g., for .psd files)

πŸ“ˆ 28. Git Analytics & Stats

  • Generate contributor graphs (git shortlog, git fame)
  • Generate churn stats (git log --stat)
  • Track contribution activity with git log --since or GitHub Insights

πŸ” 29. Git Replace & Filter Branch

  • git replace to swap objects in history
  • git filter-branch for complex rewriting
  • Use with caution β€” avoid on shared history

🌐 30. Git Across Environments

  • Use Git with GitHub CLI (gh)
  • Use Git in CI runners and scripts
  • Use Git in Docker images for automation
  • Access GitHub/GitLab via REST API

About

Master Git step-by-step from beginner to advanced. Check off tasks as you complete them!

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published