Git Commands

Everyday Git commands for commits, branches and remotes. Every item below is clearly marked as a shortcut, command, or syntax reference.

Most Useful Git Commands

GitCommand

Clone Repository

Type this command
git clone <url>

Copies a remote repository to your computer.

Learn More
GitCommand

Check Status

Type this command
git status

Shows changed, staged and untracked files.

Learn More
GitCommand

Stage All Changes

Type this command
git add .

Stages every changed file for the next commit.

Learn More
GitCommand

Commit with Message

Type this command
git commit -m "message"

Records staged changes with a message.

Learn More
GitCommand

Push to Remote

Type this command
git push

Uploads local commits to the remote branch.

Learn More
GitCommand

Pull from Remote

Type this command
git pull

Fetches and merges changes from the remote branch.

Learn More
GitCommand

Switch Branch

Type this command
git switch <branch>

Switches to an existing branch.

Learn More
GitCommand

Create and Switch Branch

Type this command
git switch -c <name>

Creates a new branch and switches to it.

Learn More

More Git Commands

Frequently Asked Questions

What are the most useful Git commands?

Common Git commands include Clone Repository (git clone <url>), Check Status (git status), Stage All Changes (git add .), Commit with Message (git commit -m "message"), Push to Remote (git push).

Where do I type Git commands?

Type each command in the terminal or command-line interface used by Git.

What should I check before running a Git command?

Read its reference page and the linked documentation for prerequisites and placeholders. Check the current directory and target before running commands that change or delete data.