Git tracks changes to your code over time, letting multiple people collaborate without overwriting each other's work. GitHub hosts Git repositories and adds collaboration tools on top.

What is Git?

Git records snapshots ("commits") of your project, so you can review history, undo mistakes and work on parallel versions of the code.

Basic Commands

bash
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/you/repo.git
git push -u origin main

Branching

A branch is an independent line of development. Create one for each feature or fix so main always stays deployable.

bash
git checkout -b feature/login-page
git add .
git commit -m "Add login page"
git push origin feature/login-page

Pull Requests

A pull request proposes merging your branch into another, giving teammates a chance to review the diff and leave comments before it's merged.

Merge Conflicts

Conflicts happen when two branches change the same lines differently. Git marks the conflicting sections in the file so you can manually choose what to keep.

Resolve a conflict by editing the file to remove the <<<<<<< / ======= / >>>>>>> markers, then commit the result.

GitGitHubDevOps