ad

Git Command Generator

Build complex git commands visually — fill in parameters and copy.

Create & switch to branch

Create a new branch and switch to it

$ git checkout -b feature/my-feature

Delete local branch

Delete a local branch (force optional)

$ git branch -d old-branch

Delete remote branch

Delete a branch from the remote

$ git push origin --delete old-branch

Rename branch

Rename the current branch

$ git branch -m new-branch-name

List all branches

List local and remote branches

$ git branch -a

Amend last commit

Modify the last commit message

$ git commit --amend -m "Updated commit message"

Commit with message

Stage all and commit

$ git add . && git commit -m "feat: add new feature"

Squash last N commits

Squash recent commits into one

$ git reset --soft HEAD~3 && git commit -m "Combined changes"

Cherry-pick commit

Apply a specific commit to current branch

$ git cherry-pick abc1234

Undo last commit (keep changes)

Undo commit but keep files staged

$ git reset --soft HEAD~1

Undo last commit (unstage)

Undo commit and unstage files

$ git reset HEAD~1

Discard all local changes

Reset to last commit (destructive)

$ git checkout -- .

Revert a commit

Create a new commit that undoes changes

$ git revert abc1234

Unstage a file

Remove file from staging area

$ git reset HEAD src/index.ts

Add remote

Add a new remote repository

$ git remote add origin https://github.com/user/repo.git

Push with upstream

Push and set upstream tracking

$ git push -u origin main

Force push (safe)

Force push with lease (safer)

$ git push --force-with-lease origin feature-branch

Fetch and prune

Fetch remote and clean stale refs

$ git fetch --prune origin

Stash with message

Stash changes with a description

$ git stash push -m "WIP: feature work"

Apply specific stash

Apply a specific stash entry

$ git stash apply stash@\{{0}\}

List stashes

Show all stash entries

$ git stash list

Pop stash

Apply and remove the latest stash

$ git stash pop

Pretty log

One-line log with graph

$ git log --oneline --graph --decorate -n 20

Log by author

Show commits by a specific author

$ git log --author="John" --oneline -n 10

Diff between branches

Show commits in branch A not in B

$ git log main..feature --oneline

Search commit messages

Find commits by message content

$ git log --grep="fix bug" --oneline

Set user name

Set git username (global)

$ git config --global user.name "John Doe"

Set user email

Set git email (global)

$ git config --global user.email "john@example.com"

Set default branch

Set default branch name for new repos

$ git config --global init.defaultBranch main

Categories

  • Branch — Create, delete, rename branches
  • Commit — Amend, squash, cherry-pick
  • Undo — Reset, revert, unstage
  • Remote — Push, fetch, force-push safely
  • Stash — Save and restore work in progress
  • Log — Pretty logs, search, diff between branches
  • Config — Set username, email, defaults
ad