Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

These five Git commands cover the core loop of checking changes, selecting what belongs in a commit, recording it, integrating upstream work, and sharing your commits. Together they make a useful everyday workflow: git status → git add → git commit → git pull or git push.

How the five commands fit together

Git work moves through three local states: the working tree contains your current files, the index (or staging area) holds the content selected for the next commit, and HEAD identifies the current committed history. git status helps you see differences between those states. git add selects content for the index, and git commit records the staged snapshot. Pull and push exchange work with an upstream repository: pull brings upstream work into the current branch, while push shares local commits.

The examples below assume you are inside a Git repository. Remotes, branch settings, and team policies vary, so follow the workflow configured for your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Check the repository with git status

Run git status after editing and before committing. It reports paths that differ between the working tree and index, paths staged relative to the current HEAD, and untracked files that Git is not ignoring. That gives you a checkpoint before you decide what to stage.

git status

Human-readable output is enough for routine checks. Ignored files ordinarily do not appear as untracked files. Output can vary with Git version and configuration; for scripts, the manual documents short output and a stable porcelain format. Some submodule states require additional care. Check your installed version with git --version.

2. Choose what enters the next snapshot with git add

git add copies the specified file contents, as they exist when the command runs, into the index. For example, stage one file with:

git add src/example.js

To stage only selected changes within a file, use interactive patch mode:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git add -p src/example.js

Because staging captures the file at that moment, edits made afterward are not automatically included in the staged version. Run git add again for the later edits you want in the commit. Ignored files are not added by default. Staging deliberately helps keep unrelated work out of a snapshot.

3. Record the staged snapshot with git commit

A regular git commit records staged changes; it does not automatically include every unstaged edit visible in the working tree. Review the staged content and repository state before recording it:

git status
git diff --cached
git commit -m "Describe the change"

The commit message should make the change understandable later. The Git user manual suggests a short first line, with more detail afterward when useful; this is a convention, not a strict requirement.

The -a option to git commit stages modifications and removals of already tracked files as part of the commit. It does not include new untracked files, so check status rather than assuming it captures everything.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Integrate upstream work with git pull

git pull obtains upstream changes and integrates them into the current work. It is not simply a command that makes every local file match the remote: branches can diverge, and integration can produce conflicts that need attention.

git status
git pull

Before pulling, check the repository state and follow the project’s expected workflow. If Git reports conflicts or requests a decision about integration, read the output and resolve the situation according to your team’s process. The integration strategy and defaults depend on Git version and configuration; there is no single setting to prescribe for every repository.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Share local commits with git push

After creating commits, git push is the command used to share local work with a remote repository. Git groups it among the commands for sharing and updating projects.

git push

Whether that exact invocation is sufficient depends on the repository’s remote and branch configuration. Use the command and setup specified by your project; the command name alone does not establish how authentication, branch protections, or rejected updates are handled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The everyday sequence

  1. git status to inspect staged, unstaged, and untracked work.
  2. git add <file> or git add -p to select what belongs in the next snapshot.
  3. git status and, when useful, git diff --cached to review the selection.
  4. git commit to record the staged changes.
  5. git pull to integrate upstream work when appropriate, or git push to share local commits.

For command-specific details, see the Git Project manuals for git status, git add, git commit, and git pull, along with its command reference and user manual.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.