Git fundamentals
Repositories, commits, branches, merging and remotes.
Level 101 · 18 lessons · 15 practice labs
Lessons
Your first repository
- Git setup and identity: You will install Git and set your name and email so every change is recorded under the right person.
- Starting a Git repository and status: You will start a new repository and read git status to see which files are tracked and which have changed.
- The Git staging area and commits: You will move changes to the Git staging area and save them as a commit with a meaningful message.
- Writing good commit messages
- Git history and differences: log, diff: You will list past commits in Git and use diff to see what changed between two versions.
- Short task: turn a scripts folder into a repository
Fixing and leaving things out
- Undoing in Git: unstage, restore, amend, revert: You will use Git to pull back a staged change, restore a file to its old state and fix the last commit.
- .gitignore and secrets: You will use .gitignore to leave some files untracked and keep secrets such as passwords out of the repository.
- Short task: take an accidentally added password file out of a commit
Branches
- Git branches: You will open a Git branch to work on something new without disturbing the main code and switch between branches.
- Merging and resolving conflicts in Git: You will merge branches in Git and resolve by hand the conflict that appears when the same line was changed in two places.
- Git stash: setting half-done work aside: You will use Git to set half-finished work aside, switch to another task and bring the work back later.
- Git tags: You will mark an important version with a Git tag and later return to exactly that point.
- Short task: make an urgent fix on its own branch and merge it into main
Remotes and recovery
- Git remotes: clone, push, pull: You will use Git to clone a remote repository and send (push) and receive (pull) changes.
- Reset and recovery with Git reflog: You will use reset to step back in history and recover accidentally lost commits from the reflog record.
- Short task: bring back a commit that seems lost using reflog
Wrap-up
- Capstone: manage a configuration repository with Git: You manage a fictional company's configuration files in Git, tracking changes with branches, commits and tags and keeping secrets out of the repository.
Practice labs
- Two changes in one file: Split two unrelated changes in Piril Bakery’s recipe file into two separate commits with git add -p and show with git log -p that each commit holds one topic.
- Commits made with a personal email: Set the work identity for Kuzey Logistics’ repository only, fix the author of the last commit and prove with git log --format that new commits carry the right identity.
- Three clean commits from a messy working tree: Turn a messy working tree with new files, deleted files and a rename into three meaningful commits, leaving git status clean and git show --stat showing each commit is coherent.
- A log file staged by mistake: Unstage the log file that was added by mistake without losing its changes and show with git status that it now lives only in the working tree.
- Undo a shared bad commit: Undo the already-pushed commit that broke Cinnamon Café’s menu site without rewriting history, proving the file is back to its old state and the history is intact.
- Three different mistakes in recent commits: Fix the wrong message, the extra file and the accidentally deleted configuration in the unpushed recent commits with the right undo commands and show that the check script passes.
- .gitignore is not working: Stop tracking the already-tracked build folder without deleting its files, add it to .gitignore and prove that git status no longer shows it.
- Ignore everything but one: Write .gitignore rules that ignore all log and temp files but keep tracking the sample configuration file, and verify each file with git check-ignore -v.
- Which rule is hiding the file?: Find which rule among global excludes, .git/info/exclude and nested .gitignore files hides a needed file, fix only that rule and show the file can be committed again.
- Same line on two branches: Resolve the conflict caused by two branches changing the same line of Atlas Clinic’s booking configuration, finish the merge and show the result with git log --graph.
- An urgent fix in the middle of work: Set your half-done work aside with stash including untracked files, make and merge the urgent fix on its own branch, then bring your work back and resolve the conflict that appears.
- A deleted-versus-modified conflict: Resolve the conflicts from files one branch deleted while the other edited and moved them, making the right call for each, and show the test script passes on the merged branch.
- A rejected push: Fix the push rejected by the lab’s bare remote by bringing the remote changes under your commit, and show with git log that both pieces of work survive.
- Bring back a deleted branch: Find the last commit of a feature branch deleted before it was merged using reflog, recreate the branch and show its files are back.
- A moved remote and missing tags: Update the remote whose address changed, reconnect the broken tracking branches, push the release tags that were never sent and prove with git ls-remote the remote is complete.
About this course
Repositories, commits, branches, merging and remotes.
What you will learn
- Your first repository
- Fixing and leaving things out
- Branches
- Remotes and recovery
- Wrap-up
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.