0% found this document useful (0 votes)
15 views6 pages

GIT Cheat Sheet

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

GIT Cheat Sheet

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

GIT Cheat Sheet

Sivesh Kumar | @CodeWithSivesh


Save for later
Workflow
CREATE
init | clone

BROWSE
status | log | branch

CHANGE

REVERT
reset | checkout | revert

UPDATE
pull | fetch | merge | am

BRANCH
checkout | branch

COMMIT
commit

PUBLISH
push | format-patch

Sivesh Kumar | @CodeWithSivesh


Save for later

Setting up Git
Configure User Information:

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


git config --global user.email "[email protected]"

Creating and Cloning Repositories

git init #Create a new Git repository

git clone <repository_url> #Clone an existing repository

Sivesh Kumar | @CodeWithSivesh


Save for later

Basic Commands

git status #Check the status of your repository


git add <file(s)> #Add changes to the staging area
git commit -m "Your commit message" #Commit changes
git log #View commit history
git reset --soft HEAD^ #Undo last commit (soft)
git reset --hard HEAD^ #Undo last commit (hard)

Branching and Merging

git branch <branch_name> #Create a new branch


git checkout <branch_name> #Switch to a branch
git checkout -b <branch_name> #Create and switch to a new branch
git merge <branch_name> #Merge branches
git branch -d <branch_name> #Delete a branch

Sivesh Kumar | @CodeWithSivesh


Save for later

Remote Repositories

git remote add origin <repository_url> #Add a remote repository


git push -u origin <branch_name> #Push changes to a remote
repository
git pull origin <branch_name> #Pull changes from a remote
repository

Miscellaneous

git diff <commit_hash1> <commit_hash2> #See changes between


commits
git show --name-only #Show files changed in the last commit
git checkout -- <file(s)> #Discard changes in working directory

Sivesh Kumar | @CodeWithSivesh


Sivesh Kumar
TECHNICAL LEADER

@CodeWithSivesh

Follow For More !

Thank you for reading!

You might also like