Tsallaka zuwa abun ciki
Justice Tech School

Git Tutorial

Track changes, branch safely and collaborate with version control.

Start learning Git
Getting started5 lessons
  1. 1Git IntroductionVersion control in plain words.
  2. 2Setup and git initConfigure your name and create a repo.
  3. 3Git ConfigSettings live at three levels: system, global (your user) and local (one repo).
  4. 4Version and Helpgit --version shows the installed version and git help <command> opens the manual for any .
  5. 5Inside the .git FolderGit stores everything in the hidden .git folder: HEAD points at the current branch, object.
Basics39 lessons
  1. 6Staging and CommittingThe core workflow.
  2. 7Status and LogSee what changed and what happened.
  3. 8DiffCompare changes.
  4. 9.gitignoreKeep files out of Git.
  5. 10Undoing Changesrestore, reset and amend.
  6. 11Writing Commit MessagesA good message has a short summary in the imperative mood, such as Add login form.
  7. 12Staging Selected Filesgit add takes a path, so you can stage only some of your changes.
  8. 13Removing and Renaming Filesgit rm deletes a file and stages the deletion.
  9. 14Listing and Showing Filesgit ls-files lists tracked files.
  10. 15Commit Tracked Changes in One Stepgit commit -a stages all modified tracked files before committing.
  11. 16What Is Version ControlVersion control records every change to your files so you can go back, compare and work to.
  12. 17Working Tree, Index and RepositoryFiles move through three areas: the working tree where you edit, the index (staging area) .
  13. 18Your First Commitgit add stages files and git commit saves a snapshot with a message.
  14. 19Reading git statusgit status shows staged, unstaged and untracked files.
  15. 20Viewing Changes with diffgit diff shows unstaged changes.
  16. 21Reading the Loggit log lists commits.
  17. 22The .gitignore FileList patterns of files Git should not track, such as build output and secrets.
  18. 23Amending the Last Commitgit commit --amend changes the last commit message or adds forgotten files.
  19. 24Discarding Changesgit restore file throws away working changes and git restore --staged unstages.
  20. 25Looking Inside a Commitgit show prints a commit and its changes.
  21. 26Lightweight TagsTags name a commit, such as a release.
  22. 27Renaming and Movinggit mv renames and stages.
  23. 28Staging Parts with add -pgit add -p stages selected hunks.
  24. 29Empty Commits and Messages--allow-empty makes a commit with no changes, handy to trigger CI.
  25. 30AliasesAliases shorten long commands.
  26. 31Configuring Gituser.name, user.email, core.editor and init.defaultBranch are common settings.
  27. 32Getting Helpgit help command opens the manual and command -h prints a short usage.
  28. 33Looking at Old Versionsgit show and git restore let you view or take old versions without moving branches.
  29. 34Finding Changes with log -Sgit log -S finds commits that added or removed a piece of text.
  30. 35Comparing Branchesgit diff a..b and git diff --stat compare branches.
  31. 36Cherry Pickgit cherry-pick copies one commit onto the current branch.
  32. 37Squash Mergemerge --squash combines a branch into one staged change you commit yourself.
  33. 38Rebase Basicsrebase replays your commits on top of another branch for a straight history.
  34. 39Graph View--graph draws the branch shape and --all includes every branch.
  35. 40Bare RepositoriesA bare repository has no working tree and is what servers hold.
  36. 41A Daily Solo WorkflowPull, branch, commit often, merge, push.
  37. 42Practice: Make a ReleaseCommit, tag and list.
  38. 43Practice: Undo a MistakeRevert a bad commit and verify.
  39. 44Practice: Feature and MergeBranch, work, merge, clean up.
Inspecting history6 lessons
  1. 45Log Formatsgit log has many formats: --oneline, --format with placeholders like %an (author) and %s (.
  2. 46Filtering the LogFilter by author, message text, date or path.
  3. 47Inspecting a Commitgit show prints one commit and its diff.
  4. 48Blame: Who Changed This Linegit blame shows who last changed each line.
  5. 49Diff Variantsgit diff compares working tree and index.
  6. 50Shortlog and git grepgit shortlog -sn counts commits per author.
Undoing changes13 lessons
  1. 51Restore and Unstagegit restore file discards working changes.
  2. 52Reset: Soft, Mixed and Hard--soft moves the branch only.
  3. 53Revert: Undo Safelygit revert creates a new commit that reverses an earlier one.
  4. 54Clean Untracked Filesgit clean removes untracked files.
  5. 55Stash In Depthgit stash saves dirty work and cleans the tree.
  6. 56reset --soft and --mixed--soft moves the branch and keeps changes staged.
  7. 57reset --hard--hard moves the branch and resets files.
  8. 58Revert a Commitgit revert makes a new commit that undoes an old one without rewriting history.
  9. 59Cleaning Untracked Filesgit clean -n shows what would be deleted and -f deletes.
  10. 60Stashing Workgit stash saves unfinished changes and cleans the tree.
  11. 61Stash List and NamesName stashes with push -m and list them.
  12. 62The Reflog Safety NetThe reflog lists where HEAD has been, so you can recover from resets.
  13. 63Fix a Forgotten FileStage the forgotten file and amend the last commit.
Branches21 lessons
  1. 64BranchesWork in parallel.
  2. 65MergingCombine branches.
  3. 66Merge ConflictsFix clashing changes.
  4. 67Tags and StashMark releases and park work.
  5. 68Managing BranchesList with git branch, create with git branch name, rename with -m and delete merged branch.
  6. 69Switch Branchesgit switch changes branches and git switch -c creates and switches.
  7. 70Fast-forward and Merge CommitsIf main has not moved, a merge just fast-forwards.
  8. 71Aborting a MergeIf a merge goes wrong, git merge --abort returns to the state before it started.
  9. 72Annotated Tags and DescribeAnnotated tags store a message and tagger.
  10. 73Worktrees: Several Branches at Oncegit worktree add checks out another branch into a new folder that shares the same reposito.
  11. 74Creating BranchesA branch is a movable pointer to a commit.
  12. 75Switching Branchesgit switch moves between branches and updates your files.
  13. 76Renaming and Deleting Branchesgit branch -m renames and -d deletes a merged branch.
  14. 77Fast Forward MergeWhen main has not moved, merging a branch just moves the pointer forward.
  15. 78Merge CommitsIf both branches moved, Git makes a merge commit with two parents.
  16. 79Resolving a ConflictA conflict happens when both branches change the same lines.
  17. 80Aborting a Mergegit merge --abort returns to the state before the merge.
  18. 81Listing and Comparing Branchesgit branch -v shows last commits, --merged lists merged branches and git log a..b shows co.
  19. 82Branch NamingUse short lowercase names with a prefix such as feature/login or fix/typo.
  20. 83Detached HEADChecking out a commit instead of a branch gives a detached HEAD.
  21. 84Getting a File from Another Commitgit restore --source takes a file from any commit.
Remote and teamwork15 lessons
  1. 85Remotes: clone, push and pullShare your work.
  2. 86GitHub FlowBranches and pull requests.
  3. 87Working With a RemoteA remote is another copy of the repository.
  4. 88Fetch versus Pullgit fetch downloads new commits without touching your branch.
  5. 89SubmodulesA submodule pins another repository at a commit inside yours.
  6. 90Pull Requests and ForksA fork is your own copy of someone else repository on the host.
  7. 91Cloninggit clone copies a repository and sets origin.
  8. 92Adding a RemoteA remote is a named URL.
  9. 93Upstream and TrackingA tracking branch knows its remote counterpart so status can show ahead and behind.
  10. 94Remote BranchesRemote tracking branches look like origin/main.
  11. 95Deleting Remote BranchesPush with --delete removes a branch on the remote.
  12. 96Pull Request FlowCreate a branch, commit, push it and open a pull request on the hosting site.
  13. 97Pushing TagsTags are not pushed by default.
  14. 98Push and Pullpush sends commits to the remote and pull fetches and merges new ones.
  15. 99fetch Without Merginggit fetch downloads new work but does not change your branch.
Advanced GitPremium14 lessons
  1. 100RebaseA straighter history.
  2. 101Cherry-pick and ResetMove and rewind commits.
  3. 102Reflog and BisectRecover and hunt bugs.
  4. 103Hooks, Aliases and Good HabitsAutomate and stay tidy.
  5. 104Squashing CommitsSquash several small commits into one clean commit with git reset --soft followed by a new.
  6. 105Fixup and Autosquashgit commit --fixup marks a commit to be folded into an earlier one.
  7. 106Rebase --ontogit rebase --onto moves a range of commits onto a new base.
  8. 107Reflog: Recover Lost CommitsThe reflog records every place HEAD has been.
  9. 108Bisect: Find the Bad Commitgit bisect binary searches history for the commit that broke something.
  10. 109Hooks: Block Bad CommitsHooks are scripts in .git/hooks.
  11. 110Aliases and Config TricksAliases shorten long commands.
  12. 111.gitattributes and Line Endings.gitattributes sets per path rules such as line endings and diff behaviour.
  13. 112Shallow and Partial Clones--depth 1 downloads only the latest commit, which speeds up big repositories and CI jobs.
  14. 113Notes and Archivegit notes attach extra text to a commit without changing it.
Git in practicePremium6 lessons
  1. 114Debugging .gitignoregit check-ignore -v tells which rule ignores a file.
  2. 115Detached HEADChecking out a commit directly leaves HEAD detached, which means no branch follows your ne.
  3. 116Branching StrategiesTrunk based development uses short lived branches merged into main often.
  4. 117Keeping Secrets Out of GitNever commit passwords or keys.
  5. 118Git with CI and Code ReviewCI runs tests on every push.
  6. 119Troubleshooting Common ProblemsCommon fixes: undo the last commit but keep work with reset --soft, change the last messag.
Next steps1 lessons
  1. 120What Next?Where to go after the basics.