# Git and GitHub Workflow

> Track your solutions and projects with Git: commits, branches, merging, remotes and pull requests, the workflow every internship team uses. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/cs-fundamentals/git-version-control
Last updated: 2026-11-28

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](https://git-scm.com/book/en/v2) (git-scm.com)
- [Learn Git Branching](https://learngitbranching.js.org/) (learngitbranching)
- [Missing Semester: Version Control](https://missing.csail.mit.edu/2020/version-control/) (MIT)

Previous: [Complexity Analysis](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/complexity-analysis) · Next: [Modular Arithmetic and Counting](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/modular-arithmetic-combinatorics)

## More in Your Problem-Solving Toolkit

- [C++ for DSA](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/cpp-for-dsa)
- [Java for DSA](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/java-for-dsa)
- [Python for DSA](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/python-for-dsa)
- [Complexity Analysis](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/complexity-analysis)
- [Git and GitHub Workflow](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/git-version-control)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [CS Fundamentals and Placement Prep Roadmap](https://www.internhack.in/roadmaps/tracks/cs-fundamentals)
