A
Aura Dev

Git Cheatsheet

Common Git commands and usage.

Setup

git config --global user.name "name"

Set global username

git config --global user.email "email"

Set global email

git init

Initialize a new repository

git clone <url>

Clone a repository

Changes

git status

Check status of working directory

git add <file>

Add file to staging area

git add .

Add all files to staging area

git commit -m "msg"

Commit staged changes

git commit --amend

Modify last commit

Branching

git branch

List branches

git branch <name>

Create new branch

git checkout <name>

Switch to branch

git checkout -b <name>

Create and switch to branch

git merge <branch>

Merge branch into current

git branch -d <name>

Delete branch

Syncing

git remote -v

List remotes

git fetch

Fetch changes from remote

git pull

Fetch and merge changes

git push

Push changes to remote

git push -u origin <branch>

Push new branch to remote

Undoing

git reset <file>

Unstage a file

git checkout -- <file>

Discard changes in file

git revert <commit>

Create new commit reversing changes

git reset --hard <commit>

Reset to commit (destructive)

Log

git log

Show commit history

git log --oneline

Show compact history

git diff

Show unstaged changes

git show <commit>

Show changes in commit

What is Git?

Git is a distributed version control system that tracks changes in source code during software development.

This cheatsheet provides quick access to essential Git commands for branching, merging, committing, and collaborating with other developers.

Sponsored LinkAdvertisement Space (728x90)