Tools/developer/git command generator

Git Command Generator

Describe what you want to do with Git and get the exact command without memorizing complex syntax.

30 commands

Create and switch to a new branch

git checkout -b <branch-name>

Stage all changes

git add .

Stage specific file

git add <file>

Commit with a message

git commit -m "<message>"

Amend the last commit message

git commit --amend -m "<new-message>"

Only amend unpushed commits

Push current branch to origin

git push origin HEAD

Pull and rebase onto origin

git pull --rebase origin <branch>

Merge branch into current

git merge <branch-name>

Rebase current onto another branch

git rebase <base-branch>

Stash uncommitted changes

git stash push -m "<description>"

Apply most recent stash

git stash pop

List all stashes

git stash list

Undo last commit but keep changes

git reset --soft HEAD~1

Discard all local changes

git checkout -- .

Irreversible — use with caution

View commit log (pretty)

git log --oneline --graph --decorate --all

Show what changed in last commit

git show HEAD

Show diff of unstaged changes

git diff

Show diff of staged changes

git diff --cached

Cherry-pick a commit

git cherry-pick <commit-hash>

Tag the current commit

git tag -a v<version> -m "<message>"

Delete a local branch

git branch -d <branch-name>

Delete a remote branch

git push origin --delete <branch-name>

Fetch and prune deleted remote branches

git fetch --prune

Find which commit introduced a bug (bisect)

git bisect start git bisect bad git bisect good <known-good-commit>

See who changed each line of a file

git blame <file>

Search commit messages

git log --all --grep="<keyword>"

Reset file to version in last commit

git checkout HEAD -- <file>

Squash last N commits

git rebase -i HEAD~<N>

Clone a specific branch

git clone -b <branch> <repo-url>

Set upstream for current branch

git branch --set-upstream-to=origin/<branch>