Sunday, 14 June 2015

Common GIT Commands for New Developers

Common GIT Commands for New Developers

GIT commands

I am sharing my knowledge about some common GIT commands which may helpful for someone.

* initialize git instance
git init 

*  add origin
git remote add origin [GIT-URL]

*by default branch 
master

* pull direct from url
git pull url master

* create new branch branch1
git checkout -b branch1

* push new branch to origin
git push -u origin branch1

* see current branches
git branch

* see all branches
git branch -a

* reset code to previous pull
git reset --hard

* reset code to specific commit hash
git reset --hard [COMMIT-HASH]

* fetch all branches
git fetch --all

My suggestions to new developers, make habit using GIT GUI to push any code on the repository instead of directly using command line commands. If you very expert of GIT commands then only use command line otherwise you may any such code which can break production environment and put you in trouble.


For more information on GIT branches check GIT Website.

No comments:

Post a Comment

Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...