Git Command Generator

Find the right Git command for any task. Searchable reference with examples.

How to use: Pick a Git operation and fill in the details to get the right command.

Initialize a new repository

git init

Creates a new .git directory in the current folder.

Clone a repository

git clone <url>

Download a remote repository to your local machine.

Stage all changes

git add .

Add all modified and new files to staging area.

Commit changes

git commit -m "message"

Save staged changes with a descriptive message.

Push to remote

git push

Upload local commits to the remote repository.

Pull from remote

git pull

Fetch and merge changes from the remote repository.

Check status

git status

Show the working tree status and staged changes.

View commit history

git log --oneline

Show compact commit log with one line per commit.

List branches

git branch

Show all local branches. Add -a for remote branches.

Create branch

git branch <name>

Create a new branch from the current HEAD.

Switch branch

git checkout <branch>

Switch to an existing branch.

Create & switch

git checkout -b <branch>

Create a new branch and switch to it immediately.

Merge branch

git merge <branch>

Merge another branch into the current branch.

Stash changes

git stash

Temporarily store modified tracked files.

Apply stash

git stash pop

Re-apply the most recently stashed changes.

Reset to last commit

git reset --hard HEAD

Discard all changes since the last commit.

Revert a commit

git revert <commit>

Create a new commit that undoes a previous commit.

View changes

git diff

Show unstaged changes in your working directory.

View remotes

git remote -v

Show remote repository URLs.

Create tag

git tag <name>

Create a lightweight tag at the current commit.

Cherry-pick

git cherry-pick <commit>

Apply a specific commit to the current branch.

Rebase

git rebase <branch>

Reapply commits on top of another branch.