Git & GitHub
Every piece of code at Codinative lives in Git and is shared through GitHub. You don't need to be an expert - just comfortable enough to work day to day. This is the practical minimum to get there.
What they are
Git is a version-control system: it records snapshots of your project over time so you can review history, undo mistakes, and work on features in isolation. GitHub hosts Git repositories online and adds collaboration on top - pull requests, code review, and issues. In short: Git is the tool on your machine; GitHub is where the team’s code lives and gets reviewed.
One-time setup
Install Git, then tell it who you are (this stamps your commits):
git --version # check it's installed
git config --global user.name "Your Name"
git config --global user.email "you@codinative.com"Get a repo onto your machine by cloning it from GitHub:
git clone https://github.com/Codinative/<repo>.gitThe everyday flow
Ninety percent of Git is one loop: edit files, stage what you want to keep, commit it as a snapshot, and push it to GitHub. Changes move through four places:
Working directory
your edited files
Staging area
git add
Local repo
git commit
GitHub
git push
git status # what has changed?
git add index.html # stage one file
git add . # stage everything changed
git commit -m "Fix header spacing on mobile"
git push # send your commits to GitHub
git pull # get teammates' commitsAdd sticky add-to-cart to product page), not “update”.Branches & merging
A branch is an isolated line of work. You never build directly on main - you branch off, do your work, then merge it back once it’s reviewed. This keeps main stable and lets several people work at once.
git switch -c feat/sticky-atc # create + switch to a new branch
# ...edit, add, commit as usual...
git push -u origin feat/sticky-atc # publish the branch to GitHub
git switch main # switch back to main
git merge feat/sticky-atc # merge the branch into main (locally)In practice you rarely merge locally. Instead you push the branch and open a Pull Request (PR) on GitHub - a place for teammates to review the change and discuss it before it’s merged into main.
feat/… for features, fix/… for bug fixes, chore/… for maintenance.Resolving conflicts
A merge conflict happens when two branches change the same lines and Git can’t decide which to keep. It pauses and marks the spot in the file:
<<<<<<< HEAD
color: red; // the change already on your branch
=======
color: blue; // the incoming change
>>>>>>> feat/new-theme- Open each marked file and edit it to the correct final result.
- Delete the
<<<<<<<,=======, and>>>>>>>marker lines. - Stage the resolved files and finish:
git add .thengit commit(orgit merge --continue/git rebase --continue).
Stashing & rebasing
Stash shelves your uncommitted changes so you can switch tasks with a clean working directory, then bring them back later:
git stash # shelve your current changes
git switch main # do something else
git stash pop # reapply the shelved changesRebase replays your branch’s commits on top of the latest main, giving a clean, linear history. It’s the tidy way to update a feature branch:
git switch feat/sticky-atc
git pull --rebase origin main # replay your work on top of the latest mainmain - on shared branches, prefer a normal merge.How we use it here
Learn Git & GitHub
Pick the hands-on course to build the habit, and keep the reference docs handy; you’ll learn the rest by doing.
- GitHub Skills - GitHub’s own interactive, hands-on courses on Git, GitHub, and pull requests.
- GitHub Docs - Get started - the official guide to Git basics and working on GitHub.
- Pro Git book - the free, official Git book; the definitive reference.