# Git and GitHub

> Track every change with Git, collaborate through branches and pull requests on GitHub, and keep a clean public history recruiters can read. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/git-and-github
Last updated: 2026-11-28

Track every change with Git, collaborate through branches and pull requests on GitHub, and keep a clean public history recruiters can read.

Beginner · about 6 hours · difficulty 2/5

Learn first: [Terminal and Command Line](https://www.internhack.in/roadmaps/tracks/full-stack/terminal-basics)

Git is the undo button, the collaboration tool and the portfolio for a developer. Recruiters at campus placements and startups often open your GitHub before your resume.

### Core workflow

- git init or git clone to start.
- git status, git add, git commit to save snapshots with clear messages.
- git branch and git switch to work on features without breaking main.
- git push and git pull to sync with GitHub.
- git log and git diff to see what changed and why.

### Collaboration on GitHub

- **Pull requests**: propose a branch for review, discuss, then merge.
- **Merge vs rebase**: both integrate changes; rebase rewrites history and should not be used on shared branches.
- **Merge conflicts**: happen when two people edit the same lines. Read both sides, keep the right code, test, commit.
- **.gitignore**: keep node_modules, build output and .env files out of the repo.

### Good habits

Small commits with messages like "add login form validation" beat one giant "final changes" commit. A README with setup steps and screenshots turns a repo into a portfolio piece.

### Pitfalls

- Committing secrets such as database URLs or API keys. Deleting the file later does not remove it from history; rotate the key.
- Working only on main and pushing broken code.

You are ready to move on when you can create a feature branch, open a pull request, resolve a merge conflict and explain what each command did.

## Key concepts

- **Commits, staging and history**
- **Branches and switching**
- **Remotes, push and pull**
- **Pull requests and code review**
- **Merge conflicts**
- **Rebase vs merge**
- **.gitignore and secrets hygiene**
- **Conventional commit messages**

## Mini project

Create a repo for your future portfolio site, make at least ten meaningful commits across two feature branches, deliberately create and resolve a merge conflict, and write a README with setup steps.

## Check yourself

You accidentally committed a .env file with your database password and pushed it. What are the three things you must do, in order?

## Free resources

- [Pro Git](https://git-scm.com/book/en/v2) (git-scm.com)
- [GitHub Docs: Get started](https://docs.github.com/en/get-started) (GitHub)
- [Git and GitHub Roadmap](https://roadmap.sh/git-github) (roadmap.sh)

Previous: [Terminal and Command Line](https://www.internhack.in/roadmaps/tracks/full-stack/terminal-basics) · Next: [Semantic HTML](https://www.internhack.in/roadmaps/tracks/full-stack/html)

## More in Web Foundations

- [How the Internet and the Web Work](https://www.internhack.in/roadmaps/tracks/full-stack/how-the-internet-works)
- [HTTP, Requests and Responses](https://www.internhack.in/roadmaps/tracks/full-stack/http-basics)
- [Terminal and Command Line](https://www.internhack.in/roadmaps/tracks/full-stack/terminal-basics)
- [Git and GitHub](https://www.internhack.in/roadmaps/tracks/full-stack/git-and-github)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
