Back to technologies

/git

Git CLI command reference

Everyday Git commands for version control and branch management.

16 matches

Repo Basics

5 commands

git init

Create a new Git repository in the current folder.

git clone <url>

Clone a repository from a remote origin.

git status

Check the current working tree state.

git add .

Stage all tracked and untracked changes.

git commit -m "message"

Create a commit with a message.

Branching & Sync

5 commands

git switch -c feature/new-ui

Create and switch to a new branch.

git branch -a

List local and remote branches.

git pull --rebase

Pull remote changes with a rebase strategy.

git push -u origin HEAD

Push the current branch and set upstream.

git merge main

Merge the `main` branch into the current branch.

History & Recovery

6 commands

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

View a compact visual commit history.

git diff

See unstaged changes in the working tree.

git restore .

Discard working tree changes in the current directory.

git reset --soft HEAD~1

Undo the last commit but keep changes staged.

git stash

Temporarily save local changes.

git stash pop

Restore the most recent stashed changes.