GitHub commands

Initialize as a Git repository

git init

Config Setup. User namd and email

git config --global "xyz"
git config --global ""
git config --list

Connect local repository to GitHub repository

git remote add origin
git remote -v

Push and Pull

git push origin master
git pull origin master


vim .gitignore



Creates a new folder

git clone

Clone to current directory

git clone .



git clone


git clone


git clone



git reset --soft HEAD^
git reset --hard HEAD^



Frequently used commands

Add to commit later

git add .
git add A

Get current status before commit

git status


git commit -m "My First commit"

Commit shortcut

git commit -am "My First commit"

Reset (removes all files from staging area)

git reset


List which branch you are working on

git branch
git branch -a

Create new branch

git branch whatever

Use this branch

git checkout whatever

Push to branch

git push -u origin whatever


Switch to master branch

git checkout master

Pull latest master

git pull origin master

View merged branch so far

git branch --merged


git merge whatever

Push to master

git push origin master

Delete branch

View branch merged

git branch --merged

Delete branch

git branch -d whatever

view all branch

git branch -a

Action to delete branch in GitHub

git push origin --delete whatever

Leave a Comment

Your email address will not be published. Required fields are marked *