ToolSpark

Git Command Generator

Find and copy Git commands for any task. Search by action, browse by category.

Share:𝕏fin
SetupInitialize repo
git init

Create a new Git repository in the current directory.

SetupClone repo
git clone <url>

Clone a remote repository to your local machine.

SetupSet username
git config --global user.name "Your Name"

Set your Git username globally.

SetupSet email
git config --global user.email "you@example.com"

Set your Git email globally.

BasicsCheck status
git status

Show the working tree status (modified, staged, untracked files).

BasicsStage all changes
git add -A

Stage all changes (new, modified, deleted) for the next commit.

BasicsStage specific file
git add <file>

Stage a specific file for commit.

BasicsCommit
git commit -m "message"

Record staged changes with a descriptive message.

BasicsCommit all (skip stage)
git commit -am "message"

Stage and commit all tracked file changes in one step.

BasicsView log
git log --oneline --graph

Show commit history as a compact graph.

BasicsView diff
git diff

Show unstaged changes in your working directory.

BranchesList branches
git branch -a

List all local and remote branches.

BranchesCreate branch
git branch <name>

Create a new branch from current HEAD.

BranchesSwitch branch
git checkout <branch>

Switch to an existing branch.

BranchesCreate + switch
git checkout -b <branch>

Create a new branch and switch to it.

BranchesDelete branch
git branch -d <branch>

Delete a fully merged local branch. Use -D to force delete.

BranchesRename branch
git branch -m <old> <new>

Rename a branch.

RemotePush
git push origin <branch>

Upload local commits to the remote.

RemotePull
git pull origin <branch>

Fetch and merge remote changes.

RemoteFetch
git fetch --all

Download remote changes without merging.

RemoteAdd remote
git remote add origin <url>

Link a local repo to a remote URL.

RemotePush new branch
git push -u origin <branch>

Push a new branch and set upstream tracking.

RemoteForce push
git push --force-with-lease

Force push safely (fails if remote has new commits).

MergingMerge branch
git merge <branch>

Merge another branch into the current branch.

MergingRebase
git rebase <branch>

Replay commits on top of another branch for a linear history.

MergingInteractive rebase
git rebase -i HEAD~<n>

Edit, squash, or reorder the last n commits.

MergingCherry-pick
git cherry-pick <hash>

Apply a specific commit from another branch.

MergingAbort merge
git merge --abort

Cancel an in-progress merge with conflicts.

UndoUnstage file
git reset HEAD <file>

Remove a file from staging (keep working changes).

UndoDiscard changes
git checkout -- <file>

Discard all working directory changes for a file.

UndoSoft reset
git reset --soft HEAD~1

Undo last commit, keep changes staged.

UndoHard reset
git reset --hard HEAD~1

Undo last commit and discard all changes (destructive).

UndoRevert commit
git revert <hash>

Create a new commit that undoes a previous commit.

UndoAmend last commit
git commit --amend

Edit the last commit message or add more changes.

StashStash changes
git stash

Save uncommitted changes for later.

StashPop stash
git stash pop

Restore the most recently stashed changes.

StashList stashes
git stash list

Show all saved stashes.

StashDrop stash
git stash drop

Delete the most recent stash.

TagsCreate tag
git tag v1.0.0

Create a lightweight tag at current commit.

TagsAnnotated tag
git tag -a v1.0.0 -m "Release 1.0"

Create an annotated tag with a message.

TagsPush tags
git push --tags

Push all local tags to the remote.

TagsDelete tag
git tag -d v1.0.0

Delete a local tag.

42 of 42 commands shown

Frequently Asked Questions

Related Tools