Git and GitHub Workflow
Track your solutions and projects with Git: commits, branches, merging, remotes and pull requests, the workflow every internship team uses.
Beginner · about 6 hours · difficulty 2/5
Every software team uses version control, and recruiters look at your GitHub. Start using Git now for your DSA solutions and projects so it becomes muscle memory before your internship.
The mental model
Git stores snapshots of your project. A commit is a snapshot plus a message and a pointer to its parent. A branch is just a movable label pointing at a commit. Understanding this makes merge, rebase and reset much less scary.
Daily commands
git init,git clone,git status,git add,git commit -m,git log --oneline.git branch,git switch -c feature,git merge.- Remotes:
git remote add origin,git push -u origin main,git pull,git fetch. - Undo:
git restore(discard working changes),git revert(safe undo of a pushed commit),git reset(move a branch; dangerous on shared branches).
Team workflow
Create a branch per feature, commit small focused changes with clear messages, push, and open a pull request for review. Resolve merge conflicts by editing the marked regions, then add and commit. Use .gitignore for build output, secrets and node_modules.
Interview angle
Be ready to explain merge vs rebase, what a detached HEAD is, and how you would undo a bad commit that is already pushed (revert, not reset).
Key concepts
- Commits, snapshots and history
- Staging area and .gitignore
- Branching and merging
- Remotes, push, pull, fetch
- Merge conflicts
- Pull requests and code review
- revert vs reset
- Rebase and interactive history edits
Mini project
Create a public 'dsa-journal' repo, push each solved problem in a folder per topic, create a feature branch that adds a README with your progress table, deliberately cause and resolve a merge conflict, and merge via a pull request.
Check yourself
A teammate already pulled your last commit, which broke the build. Why should you use git revert instead of git reset --hard?
Free resources
- Pro Git book (git-scm.com)
- Learn Git Branching (learngitbranching)
- Missing Semester: Version Control (MIT)