Getting Started Git Basics

Git Basics

This section of the documentation is meant for beginners new to Git. It will give you an overview of what Git is and how it works.

What is Git?

In short, Git is a distributed version control system (DVCS). But what does that mean? It means Git tracks changes to files over time, and every clone of a repository contains the full project history. Because of that, you can inspect history, make commits, and review previous changes locally without depending on a central server. However, services such as GitHub or GitLab are still useful because they provide a shared central place where teams can publish repositories, exchange changes, and collaborate on the same project.

Topics

Common Terms in Git

TermMeaning
BranchA named line of development. In practice, a branch is a movable label that points to the latest commit in that line of work.
Cherry-pickThe git cherry-pick command applies the changes from one existing commit onto your current branch as a new commit, without merging the whole branch it came from.
CheckoutThe Git command used to switch to another branch or commit. In older Git workflows, git checkout is also used to create and switch to a new branch.
CloneThe git clone command creates a new local copy of an existing repository, including its history and remote information.
CommitA commit is a saved snapshot of staged changes in the repository history, stored together with a message and metadata. You usually create one with the git commit command.
Commit hashThe unique identifier Git assigns to a commit, which lets you refer to one exact point in the project's history.
Credential managerA tool that securely stores and supplies authentication credentials, such as tokens or passwords, for Git operations.
DiffA comparison that shows what changed between two versions of a file, commit, or branch. On the command line, you usually inspect it with git diff.
Fast forwardA kind of merge where Git can simply move a branch pointer forward because there is no separate branch history to combine.
FetchThe git fetch command downloads updated commits and remote branch information without automatically changing your current branch or worktree.
File statesThe current Git status of a file, such as untracked, modified, staged, or already committed.
Forked repositoryA separate copy of a repository, usually created under another account, so you can work on it independently from the original.
HEADGit's name for your current position in repository history, usually the branch or commit you currently have checked out.
HistoryThe record of commits saved in a repository over time, showing how the project has changed.
HTTPSA web-based protocol Git can use to connect to remote repositories and transfer data over the network.
InitThe git init command creates a new Git repository in a directory.
Large File StorageAn extension, often called Git LFS, that stores large files outside normal Git object storage while keeping lightweight references in the repository.
Local repositoryThe copy of a Git repository on your own machine, including its history, branches, and local commits.
MergeThe git merge command combines another line of development into your current branch, either by fast-forwarding or by creating a merge commit.
Merge conflictA situation where Git cannot automatically combine two sets of changes and needs you to decide the final result.
Merge commitA commit Git creates when it combines two lines of history into one, usually after merging one branch into another.
PullThe git pull command brings remote changes into your current local branch by fetching them and then integrating them.
Pull requestA request to review and merge changes from one branch or fork into another shared branch, commonly used on hosting platforms like GitHub.
PushThe git push command sends your local commits to a remote repository so others can access them there.
RebaseThe git rebase command replays commits on top of a different base commit, which rewrites that branch's history as new commits.
RepositoryThe full Git project, including the working files you see on disk and the Git history that records saved changes.
Remote repositoryAnother copy of the repository hosted elsewhere that you can fetch from, pull from, or push to.
Secure Shell (SSH)A secure connection method Git can use to authenticate and communicate with remote repositories, often through SSH keys.
Squash commitsCombine multiple commits into one commit so the history becomes shorter and more focused.
Squash mergeA merge style that takes all changes from a branch and records them as one new commit on the target branch.
StagingThe process of choosing which changes should go into the next commit, instead of committing every current edit at once.
StashThe git stash command temporarily stores your uncommitted changes so you can switch tasks and restore them later.
SubmoduleA separate Git repository tracked inside another repository at a specific commit.
Tracking branchA local branch configured to follow a corresponding remote branch, making it easier to fetch, pull, and compare changes.
Trunk branchThe main shared branch of a repository, often named main or master, where the primary project history is maintained.
UpstreamThe remote branch that your local branch is configured to track by default. Commands like git pull and git push often use that upstream branch automatically once it has been set.
WorktreeThe current checked-out files on disk that you can see and edit locally.

Documentation

Search

move open Esc close

Browse the docs or start typing to filter results.