0% found this document useful (0 votes)
11 views2 pages

GIT Commands

GIT Commands
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

GIT Commands

GIT Commands
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

git push // push changes to remote repository

git fetch // fetch changes from remote repository but must be merged to see changes

git merge // merge changes that was fetched by git fetch command

git pull // fetch and merge changes from remote repository

git remote -v // show remote urls

git remote shows origin // show details of origin

git remote add myremote url //this command will add remote repo in local repository

Connecting Local Repository to Remote Repository


 Create repository on github
 Open terminal in your local repository
 Run following command
 Git remote add origin http:url (Where origin is project name, and have to paste url from github)
 Will face problem in pushing, run following command
 Git push -u origin master

To delete Branch:
Local Delete
Git branch -d master
Remote delete:
Git branch -dr origin/master
To delete from remote repository:
Git push origin –delete master

To Restore Changes:
For non-Committed Files
Git checkout HEAD file/to/restore for single file
Git reset –hard HEAD to restore all
For Committed Files
Git revert <commit hash>
Git reset –hard<commit hash>
Git reset –keep<commit Hash> to restore but keep the changes as uncommitted changes
Git push -f origin master ////force push

You might also like