notepad/git.md

34 lines
875 B
Markdown
Raw Normal View History

2019-12-31 07:48:08 +00:00
# Git
2019-12-31 10:59:02 +00:00
` git init ` Initialize git
2019-12-31 07:48:08 +00:00
` git status ` Get status
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git add <file-name> ` add file to version control
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git add . ` add all files to version control
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git commit [-m "commit message"] ` commit the changes to version control
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git log ` get the log related to git i.e. version committed
2019-12-31 10:59:02 +00:00
` git reflog ` lists all the log
2019-12-31 07:48:08 +00:00
` git branch ` get the branches present locally
2019-12-31 10:59:02 +00:00
` git checkout <file-name> ` checkout/reset the file
2019-12-31 07:48:08 +00:00
` git checkout <branch-name> ` checkout the branch
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git checkout -b <branch-name> ` create a new branch and check it out
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git merge <source-branch> ` merges the source branch into currently checked out branch
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git remote add origin <repo-uri> ` add remote repo uri
2019-12-31 10:59:02 +00:00
2019-12-31 07:48:08 +00:00
` git remote -v ` lists the remote URIs
2019-12-31 10:59:02 +00:00
` git diff ` list all the changes
` git reset [<branch-name>/<commit-hash>] ` reset the current status to given snapshot