Common GIT Commands for New Developers
* 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
* 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
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
git branch -a
* reset code to previous pull
git reset --hard
git reset --hard
* reset code to specific commit hash
git reset --hard [COMMIT-HASH]
* fetch all branches
git fetch --all
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