Skip to main content

Command Palette

Search for a command to run...

Git Basic CheatSheet

Published
2 min readView as Markdown
Git Basic CheatSheet
A

Full-Stack Web Developer

#GIT BASIC CHEATSHEET

Git Config

set user name in commit history

git config --global user.name "{name}"


set user email in commit history

git config --globaluser.email "{email address}"


enable colorization of the command line output

git config --blobal color.ui auto

Create And Clone Repositories

create a new git repository locally by adding a .git folder

git init


clone an existing online repository

git clone {url}

Making Changes

stage a single file for commiting

git add [file]


stage all file for commiting

git add .

Making Changes Cont'd

make a permanent record with a short message in versioning history

git commit -m "[message]"

Viewing Changes

show information about what state git is in

git status


list version history

git log


lists a shortened version history

git log --oneline


show all changes across files that has been not staged

git diff


show the metadata and content changes of the commit

git show [commit]

Undoine Changes And Commits

make a new commit that undoes all changes of the named commit

git revert [commit]


undoes all commits after [commit] and preserves changes locally

git reset [commit]


discards all local changes in the work and resets all the files

git reset --hard

Connect to Remote Repository

set the remote repository for your local repository

git remote add [remote name] [url]

Sync Changes

uploads all local commit from your local repository

git push [remote name] [branch]


downloads all history from the remote branch

git fetch


combines the fetched history from the remote branch into the current local branch

git merge


update your current local working branch with all new commits

git pull

Branch

create a new branch

git branch [branch name]


switches to the specified branch

git checkout [branch name]


combines the specified branch's history into the current branch

git merge [branch name]


deletes the specified branch

git branch -d [branch-name]