Select Page

Check if installed

git –version

 

Setup

git config –global user.name “Presidio Production”
git config –global user.email “presidio_production@gmail.com”
git config –list

 

Initialize git on directory

Browse the root directory of the project you want to add to git and do

git init

 

Add existing project to git

git remote add origin ssh://git@bitbucket.org/SandyRig/healthmatchup.com.git

 

Add a file to staging area

git add filename.txt

 

Add all files that were changed to the staging area

git add -A

 

Remove a file from staging area

git reset filename.txt

 

Remove everything from staging area

git reset –hard

 

Remove a file both locally and from git repo

git rm filename.txt
git push origin branch_name

 

Remove a file only from the repository

git rm –cached filename.txt
git push origin branch_name

 

Remove a directory both locally and from git repo

git rm dir_name
git push origin branch_name

 

Remove a directory only from the repository

git rm –cached dir_name
git push origin branch_name

 

Delete a brach locally

git branch -d branch_name or git branch -D branch_name

 

Delete a remote branch

git push origin –delete branch_name

 

List all branches

git branch -a

remove recent push from the active branch locally

git reset –hard HEAD~1

 

force the change on remote

git push origin +branchname

 

get commit head id of the active branch

git rev-parse –short HEAD

 

remove local changes making local branch exact copy of the remote

git fetch origin
git reset –hard origin/master