Skip to main content
🗎 Refs:
📜Official Document
Atlassian Git Tutorial
Learn Git Branching
Visual Git

Configuring user information

Set global name

Set global email

Enable automatic command line coloring

INIT/CLONE REPO

Initialize a Git repository

Clone remote repository

STASH

Stash changes

List stash

Pop stash

Drop the top of stash

STAGE & COMMIT

Show modified files in the working directory

Stage file(s)

Un-stage file(s)

More advanced usage for git-reset here

Show changed, not staged differences

Show staged, not committed differences

Commit staged changes

BRANCH & MERGE

List branches

Branching at the current commit

Checkout a branch

Merge a branch into the current branch

REMOTE INTERACTION

Retrieving updates from another repository:
  • git remote add [alias] [url]: Add a Git URL as an alias.
  • git fetch [alias]: Fetch down all branches from that Git remote.
  • git merge [alias]/[branch]: Merge a remote branch into your current branch to bring it up to date.
  • git push [alias] [branch]: Transmit local branch commits to the remote repository branch.
  • git pull: Fetch and merge any commits from the tracking remote branch.

(WIP) TRACKING PATH CHANGES

Versioning file removals and path changes:
  • git rm [file]: Delete the file from the project and stage the removal for commit.
  • git mv [existing-path] [new-path]: Change an existing file path and stage the move.

(WIP) REWRITE HISTORY

Rewriting branches and updating commits:
  • git rebase [branch]: Apply any commits of the current branch ahead of specified one.
  • git reset --hard [commit]: Clear staging area, rewrite working tree from specified commit.

(WIP) INSPECT & COMPARE

Examining logs, diffs, and object information:
  • git log: Show the commit history for the currently active branch.
  • git log branchB..branchA: Show commits on branchA that are not on branchB.
  • git diff branchB...branchA : Show differences in content between two branches.

(WIP) IGNORING PATTERNS

Preventing unintentional staging or committing of files:
  • Use .gitignore: Save patterns as strings or wildcards to ignore specific files or directories.
This cheat sheet serves as an essential guide for both beginners and experienced users to navigate common Git commands effectively.

Signing Git commits

GPG init & assign