Skip to main content

Learning path · Beginner

Git from zero

Commits, branches and pull requests, then undoing mistakes without fear.

Everything you need to use Git with confidence: saving your work, branching and merging, sharing it with others, going back when something breaks, and the workflows teams build on top.

39 pages5 chaptersabout 1.5 hours of reading

  • Version Control

Not started yet0/39 read

Start with Version Control

Progress comes from your reading history, kept only in this browser.

Chapter 1Saving your work

  1. 1Version ControlVersion Control, p. 39Version control is a system that records every change to a set of files, so you can see who changed what, return to earlier versions and work in parallel.
  2. 2GitVersion Control, p. 10Git is a free, open-source distributed version control system that tracks changes to files over time, so developers can collaborate and undo mistakes.
  3. 3RepositoryVersion Control, p. 34A repository is the storage location for a project, holding all of its files plus the complete history of every change recorded by a version control system.
  4. 4Git CloneVersion Control, p. 13Git clone is a Git command that downloads a complete copy of an existing repository, including its full history, and sets it up on your computer for work.
  5. 5Staging AreaVersion Control, p. 37The staging area in Git is a holding zone between your files and the next commit, where you place exactly the changes you want that commit to include.
  6. 6CommitVersion Control, p. 5A commit is a saved snapshot of a project's files in Git, recorded with a unique ID, an author, a timestamp, and a message describing what changed.
  7. 7Git DiffVersion Control, p. 14Git diff is a Git command that shows the exact line-by-line differences between two versions of your code, such as working files, staged changes, or commits.
  8. 8.gitignoreVersion Control, p. 1A .gitignore file is a plain-text file listing patterns for files and folders Git should not track, such as dependencies, build output, logs, and secrets.
  9. 9HEADVersion Control, p. 27HEAD is Git's pointer to what you have checked out, normally the current branch, which points to its latest commit; new commits are added where HEAD points.

Chapter 2Branches

  1. 10BranchVersion Control, p. 2A branch in Git is an independent line of development that lets you work on a feature or fix in isolation, without affecting the main code until you merge it.
  2. 11Git CheckoutVersion Control, p. 12git checkout switches to another branch or commit, or restores files to an earlier version; newer Git splits these jobs into git switch and git restore.
  3. 12MergeVersion Control, p. 29A merge in Git combines the changes from one branch into another, joining separate lines of development back together into a single, shared history.
  4. 13Fast-Forward MergeVersion Control, p. 8A fast-forward merge happens when the target has no new commits since the other branch split off, so Git just moves its pointer ahead with no merge commit.
  5. 14Merge ConflictVersion Control, p. 30A merge conflict happens when Git can't automatically combine two branches because both changed the same lines of a file, so a person must decide the result.
  6. 15RebaseVersion Control, p. 33A rebase in Git replays a branch's commits on top of another commit, rewriting history to produce a cleaner, linear sequence of changes without merge commits.
  7. 16Git StashVersion Control, p. 22Git stash is a command that temporarily saves uncommitted changes and cleans the working directory, so you can switch tasks and restore the work later.
  8. 17Detached HEADVersion Control, p. 7A detached HEAD is a Git state in which you have checked out a specific commit instead of a branch, so any new commits you make don't belong to any branch.

Chapter 3Working with others

  1. 18Git RemoteVersion Control, p. 19A Git remote is a named shortcut, such as origin, to another copy of your repository, usually on a server, that you push commits to and pull commits from.
  2. 19Git FetchVersion Control, p. 15git fetch downloads new commits, branches and tags from a remote and updates remote-tracking branches like origin/main but not your own branches or files.
  3. 20Git PullVersion Control, p. 17Git pull is a Git command that downloads new commits from a remote repository and immediately integrates them into your current local branch.
  4. 21Git PushVersion Control, p. 18Git push is a Git command that uploads your local commits to a remote repository, updating the matching branch there so others can see and use your work.
  5. 22GitHubVersion Control, p. 25GitHub is a platform for hosting Git repositories and working on code together, with pull requests, code review, issues and the largest open-source community.
  6. 23GitLabVersion Control, p. 26GitLab is a Git hosting platform combining code review, issue tracking, CI/CD pipelines and security scanning in one application, in the cloud or self-hosted.
  7. 24ForkVersion Control, p. 9A fork is a personal copy of someone else's repository on a hosting platform, letting you experiment freely and propose changes back to the original project.
  8. 25Pull RequestVersion Control, p. 32A pull request is a proposal to merge changes from one branch into another, giving teammates a place to review, discuss, and test the code before it is merged.
  9. 26Code ReviewVersion Control, p. 4A code review is the practice of having other developers check code changes before they are merged, to catch bugs, improve quality, and share knowledge.
  10. 27Squash MergeVersion Control, p. 36A squash merge combines all the commits from a branch into one new commit on the target branch, keeping the main history short and easy to read.

Chapter 4Going back

  1. 28Git ResetVersion Control, p. 20Git reset is a Git command that moves the current branch back to an earlier commit and, depending on its mode, also resets the staging area and your files.
  2. 29Git RevertVersion Control, p. 21Git revert is a Git command that undoes an earlier commit by creating a new commit with the opposite changes, leaving the existing project history intact.
  3. 30Cherry-pickVersion Control, p. 3A cherry-pick in Git copies the changes from one specific commit onto your current branch as a new commit, without merging the rest of the branch it came from.
  4. 31Git BisectVersion Control, p. 11Git bisect is a Git command that uses binary search through commit history to find the exact commit that introduced a bug, testing only a few commits.
  5. 32Git TagVersion Control, p. 23A Git tag is a named, permanent pointer to a specific commit, most often used to mark release versions such as v1.0.0 in a repository's history.
  6. 33Semantic VersioningVersion Control, p. 35Semantic versioning is a MAJOR.MINOR.PATCH numbering scheme in which each part signals whether a release breaks compatibility, adds features, or fixes bugs.
  7. 34Git HooksVersion Control, p. 16Git hooks are scripts that Git runs automatically at certain points, such as before a commit or a push, to check code, enforce rules, or automate tasks.

Chapter 5Team workflows

  1. 35Trunk-Based DevelopmentVersion Control, p. 38Trunk-based development is a branching strategy where developers merge small changes into one shared main branch at least daily, keeping it always releasable.
  2. 36GitflowVersion Control, p. 24Gitflow is a Git branching model that uses long-lived main and develop branches plus feature, release, and hotfix branches to manage scheduled releases.
  3. 37HotfixVersion Control, p. 28A hotfix is an urgent fix for a serious problem in production, such as a crash or security hole, released quickly and outside the normal release schedule.
  4. 38MonorepoVersion Control, p. 31A monorepo is a single version control repository that holds the code for many projects, such as several apps, services, and shared libraries, managed together.
  5. 39Conventional CommitsVersion Control, p. 6Conventional Commits is a specification for structured commit messages like feat: add search, so tools can write changelogs and pick versions automatically.

Along the way, compare

Pairs on this path that are easy to mix up, side by side.

More

Settings