https://github.com/thalsi/git
Master Git step-by-step from beginner to advanced. Check off tasks as you complete them!
https://github.com/thalsi/git
git github tutorial
Last synced: 1 day ago
JSON representation
Master Git step-by-step from beginner to advanced. Check off tasks as you complete them!
- Host: GitHub
- URL: https://github.com/thalsi/git
- Owner: thalsi
- Created: 2023-06-10T17:46:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-03T14:13:23.000Z (10 months ago)
- Last Synced: 2025-07-03T15:25:51.002Z (10 months ago)
- Topics: git, github, tutorial
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# β
Git Mastery Checklist (Beginner β Advanced)
---
π’ Beginner
## π§© 1. Setup & Configuration
- [x] Install Git
- [x] git config --global user.name "Your Name"
- [x] git config --global user.email "you@example.com"
- [x] Set default branch: `init.defaultBranch main`
- [x] Set default editor: VS Code, Vim, etc.
- [x] Enable color UI
- [x] View current config: `git config --list`
- [x] View current config: `git config --list --global`
---
## π 2. Git Basics
- [x] git init
- Initialize a new Git repository.
- [x] git status
- Check the status of files β modified, staged, untracked.
- [x] git add / git add .
- Stage file(s) to be committed.
- [x] git commit -m "message"
- Commit staged changes with a message.
- [x] git log / git log --oneline
- View commit history (detailed or short).
- [x] git diff
- See whatβs changed before staging.
- [x] git show
- Show the details of a specific commit.
- [x] Use .gitignore
- Ignore files you donβt want Git to track (e.g., node_modules/, env, dist).
---
## πΏ 3. Branching & Merging
1. Branching
- [x] `git branch` β List all local branches
- [x] `git branch ` β Create a new branch
- [x] `git switch ` β Switch to a branch (newer)
- [x] `git checkout ` β Switch to a branch (older method)
- [x] `git checkout -b ` β Create and switch to a new branch
- [x] `git branch -d ` β Delete a local branch (safe)
- [x] `git branch -D ` β Delete a local branch (force)
- [x] `git branch -m ` β Rename current branch
- [x] `git branch -vv` β Show branches with last commit info
- [x] `git push origin ` β Push branch to remote
- [x] `git push --set-upstream origin ` β Link local branch to remote
- [x] `git fetch --all` β Fetches all branches from all remotes (usually just origin) but does NOT merge or checkout anything.
- [x] `git fetch -p` β It tells Git to remove (prune) any remote-tracking branches that no longer exist on the remote.
2. 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
- [x] `git merge ` β Merge the given branch into the current branch
- [x] `git merge --no-ff ` β Force a merge commit even on fast-forward
- [x] `git merge --squash ` β Merge and squash into a single commit
- [x] `git merge --abort` β Abort a merge in progress
- [x] `git merge --continue` β Continue merge after resolving conflicts
---
## π 4. Remote Repositories
- [x] git remote add origin
- [x] git push -u origin main
- [x] git push / git pull
- [x] git clone
- [x] git remote -v
- [x] git push --set-upstream origin
- [x] git branch -vv
- [x] git branch --set-upstream-to
---
## π§Ό 5. Undo & History Fixing
- [x] git reset --soft / --mixed / --hard
- [x] git restore
- [x] git restore .
- [x] git restore --staged
- [x] git commit --amend
- [x] git reflog
- [x] git clean -fd
- [x] git reset --merge (undo merge)
---
π‘ Intermediate
## π 6. Rebase & Cherry-Pick
### π Cherry-pick
- [x] `git cherry-pick ` β Apply specific commit from another branch
- [x] `git cherry-pick commit1 commit2 commit3` β You can also cherry-pick multiple commits
- [x] `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
- [x] `git rebase ` β Reapply current branch commits on top of ``
- [x] `git rebase -i ` β Interactive rebase: squash, reword, drop commits
- [x] `git rebase -i HEAD~n` β Interactively edit the last `n` commits
- [x] `git rebase --autosquash` β Auto-squash commits marked with `fixup!` or `squash!`
- [x] `git rebase --continue` β Continue rebase after resolving conflicts
- [x] `git rebase --abort` β Abort the rebase and return to the previous state
- [x] `git rebase --skip` β Skip the current conflicting commit during rebase
- [x] `git pull --rebase` β Pull latest changes using rebase instead of merge
- [x] `git status` β Check status during rebase (conflicts, progress)
- [x] `git log` β Review commit history before/after rebase
- [x] Resolve conflicts manually β Fix file conflicts and mark as resolved
| Command | `git rebase -i ` 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
- [x] git tag
- [x] git tag -a -m "message"
- [x] git show
- [x] git push origin
- [x] git push --tags
---
## π¦ 8. Stashing & Cleaning
- [x] `git stash` β Stash tracked modified files
- [x] `git stash -u` β Stash tracked + untracked files (not ignored)
- [x] `git stash -a` β Stash all (tracked + untracked + ignored)
- [x] `git stash list` β View list of stashes
- [x] `git stash show` β Show summary of latest stash
- [x] `git stash show -p` β Show patch/diff of latest stash
- [x] `git stash pop` β Apply stash and delete it
- [x] `git stash apply` β Apply stash but keep it
- [x] `git stash drop` β Delete latest stash
- [x] `git stash clear` β Delete all stashes
- [x] `git stash push -m "message"` β Stash with custom message
---
## π 9. Git Inspection Tools
- [x] git log with formatting
- [x] git diff --cached
- [x] git blame
- [x] git describe
- [x] git shortlog
- [x] git shortlog -sn
---
## π₯ 10. Team Collaboration
- [x] Use Pull Requests / Merge Requests
- [x] Feature branch workflow
- [x] Gitflow workflow
- [x] Code review & approvals
- [x] Protected branches
- [x] Squash commits before merge
---
## π οΈ 11. Git Hooks & Automation
- [x] Setup Husky for hooks
- [x] Use pre-commit, commit-msg, post-merge
- [x] Use lint-staged for auto formatting
- [x] Create .husky/ scripts
- [ ] Use `git commit --no-verify` (with caution)
---
## ποΈ 12. Aliases & Tools
- [ ] Create git aliases
- [ ] Use Git GUI tools
- [ ] Use .gitattributes
- [ ] Try https://learngitbranching.js.org
- [ ] Use GitLens in VS Code
- [ ] Use `diff-so-fancy` for better diffs
---
## βοΈ 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
- [x] Use Conventional Commits (feat:, fix:, chore:, etc.)
- [x] Install commitlint
- [x] Use Commitizen (cz) for commits
- [x] 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
- [ ] https://git-scm.com/book
- [ ] https://learngitbranching.js.org
- [ ] https://ohmygit.org
- [ ] Git cheatsheets from GitHub
---
## βοΈ BONUS: Aliases to Save Time
```bash
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