< All Topics

Git Cheetsheet

Create new git repo

git init

Clone repo

git clone

Show state of current directory

git status

List commit history

git log

Show changes between the working tree and the index or a tree

git diff

Display content and metadata

git show

List all branches in the repo and show which one is being used

git branch

Switch branch

git checkout branch-name

Delete branch

git branch -d

Rename branch

git branch -m

Merge to specific branch

git merge branch-name

Stage changes

git add somefile

Stage all changes

git add .

Undo changes

git revert somefile

Show untracked files

git clean -n

Amend last commit

git commit --amend

Connection to a remote repo

git remote add

Fetch code from repo

git pull

Push the code to a branch (done after git add and git commit)

git push

Reset staging area

git reset