QUICK REFERENCE · GIT

Git Commands

Task-based lookup for everyday Git workflows. Use it when you know what you want to do and need the command quickly; deeper Git concepts remain in BrounStack's existing learning material.

Start a repository

git init

Initializes a new Git repository in the current directory.

git clone <url>

Creates a local copy of an existing remote repository.

git status

Shows branch information plus tracked, modified, staged and untracked files.

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

Sets the default author name used for commits on the machine.

Track & commit changes

git add <file>

Stages a specific file for the next commit.

git add .

Stages current-directory changes. Review with git status before committing.

git diff

Shows unstaged changes in tracked files.

git diff --staged

Shows changes currently staged for the next commit.

git commit -m "message"

Creates a commit from staged changes with a short message.

git rm <file>

Removes a tracked file and stages that removal.

Inspect history

git log

Shows commit history for the current branch.

git log --oneline

Shows a compact one-line view of commit history.

git show <commit>

Displays details and changes for a specific commit.

git blame <file>

Shows which commits last changed individual lines in a file.

Branches & merging

git branch

Lists local branches.

git switch -c <branch>

Creates a new branch and switches to it.

git switch <branch>

Switches to an existing branch.

git merge <branch>

Merges the named branch into the currently checked-out branch.

git branch -d <branch>

Deletes a local branch when Git considers it safely merged.

git stash

Temporarily stores tracked working changes so you can work with a cleaner tree.

Remote collaboration

git remote -v

Lists configured remote names and URLs.

git remote add origin <url>

Adds a remote named origin.

git fetch

Downloads remote refs and objects without merging them into your current branch.

git pull

Fetches and integrates changes for the configured upstream branch.

git push

Uploads local branch commits to its configured remote branch.

git push -u origin <branch>

Pushes a branch and sets its upstream tracking relationship.

Review & undo safely

git restore <file>

Restores a working-tree file from the index; review the change before using it because uncommitted edits can be lost.

git restore --staged <file>

Removes a file from the staging area while keeping its working-tree changes.

git revert <commit>

Creates a new commit that reverses the selected commit, preserving shared history.

git stash pop

Reapplies the most recent stash and removes it if the application succeeds.

Reference, not duplication: this page is deliberately task-based and concise. Existing BrounStack learning material remains the place for Git concepts and guided explanations. Destructive history-rewrite commands are intentionally not promoted in this beginner quick reference.