Show Menu
Cheatography

Git commands for day to day life

Working with Branches

git branch
List branches
git branch [branc­h_name]
Creates new branch
git checkout -b [branc­h_name]
Creates and switch to a new branch
git checkout [branc­h_name]
Switch to branch
git branch -d [branc­h_name]
Deletes branch
git branch -m [old_name] [new_name]
Renames branch

Working with Remote

git remote add [remot­e_name] [repos­ito­ry_url]
Add a remote repo
git pull [remot­e_name] [branc­h_name]
Pull changes from a remote repo
git push [remot­e_name] [branc­h_name]
Send changes to a remote repo

Order of Work

git init
git clone [repos­ito­ry_url]
git checkout -b [branc­h_name]
make modifi­cations
git add [file_­or_­dir­ectory]
git commit -m 'message'
git push [remot­e_name] [branc­h_name]
create pull request on UI
git fetch origin
git pull origin main
git push [remot­e_name] [branc­h_name]

Initia­lizing, Staging and Commiting

git init
Initialize the repo on git
git clone [repos­ito­ry_url]
Clone an existing repo
git add [file_­or_­dir­ectory]
Stage changes for commit
git commit -m 'message'
Commit with short message (
-m
)
git reset
Retorna para unstage
git reset [commit]
Tira arquivo do stage
 

Info

git status
Check the status of changes
git log
View commit history
git diff [commit1] [commit2]
Show changes between commits
git diff
Show changes between working directory and last commit
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Cheat Sheet