I touched on the world of a few months ago and I realized I needed a cheat sheet to navigate it. Here it is for future reference.

| git clone
| copies files into local folder
| git status
| shows difference between local package and github repository
| git push
| pushes all commits to the github repository
| git pull
| pulls all commits from the github repository
| git commit -m "message"
| -m adds a message to the commit
| (if -m is not used vim/nano opens and a message can be added)
| git add -A
| adds all files
| git add .
| adds all files in the current directory
| git branch
| shows list of branches
| git branch newBranch
| creates a new branch of the current branch
| git checkout newBranch
| makes newBranch the active branch
| git checkout newBranch
| makes newBranch the active branch
| git merge master
| attempts to merge master into newBranch
| (it always attempts to merge into the current branch)
| git log origin/master..HEAD
| shows unpushed commits
| git diff origin/master..HEAD
| shows unpushed diffs
| git reset --hard
| revert changes to modified files.
| git clean -fd
| remove all untracked files and directories.
| git stash
| saves current changes in a "stash" (without committing them)
| git stash list
| lists available stashes in a branch
| git stash apply stash@{0}
| reapply changes from stash@{0}
| git stash drop stash@{0}
| drops stash@{0}
| git log
| show the commit history
| git log -p -2
| show the differences introduced in the last 2 commits

Standard workflow consists of:

git pull
git branch
[implement feature]
git add
git commit
git push
[then pull request and merge]

That’s about it.

Leave a Reply

Your email address will not be published. Required fields are marked *