-
Notifications
You must be signed in to change notification settings - Fork 6
Git Cheatsheet
To retrieve an entire repository from a hosted location via URL:
$ git clone [url]
To show modified files in working directory, staged for your next commit:
$ git status
To show all commits in the current branch’s history:
$ git log
To add a file as it looks now to your next commit (stage):
$ git add [file]
or to add all:
$ git add .
To diff of what is changed but not staged:
$ git diff
To diff of what is staged but not yet committed:
$ git diff --staged
To commit your staged content as a new commit snapshot:
$ git commit -m “[descriptive message]”
or to open nano to write you commit message just simply:
$ git commit
To list your branches. a * will appear next to the currently active branch:
$ git branch
To create a new branch:
$ git branch [branch-name]
To switch to another branch and check it out into your working directory:
$ git checkout [branch-name]
To fetch and merge any commits from the tracking remote branch:
$ git pull [remote-name] [branch-name]
To push local branch commits to the remote repository branch:
$ git push [remote-name] [branch-name]