Do you Git it?
Created: 2015-11-27
I touched on the world of github.com a few months ago and I realized
I needed a cheat sheet to navigate it. Here it is for future
reference.
Description |
Command |
copies files into local folder |
git clone |
shows difference between local package and github repository |
git status |
pushes all commits to the github repository
pulls all commits from the github repository
|
git push
git pull
|
-m adds a message to the commit (if -m is not used vim/nano
opens and a message can be added) |
git commit -m "message"
|
stages all files for next commit
stages all files in the current directory
|
git add -A
git add .
|
shows list of branches
creates a new branch of the current branch
makes newBranch the active branch
|
git branch
git branch newBranch
git checkout newBranch
|
makes newBranch the active branch
attempts to merge master into newBranch (it always attempts to
merge into the current branch)
|
git checkout newBranch
git merge master
|
shows unpushed commits
|
git log origin/master..HEAD
|
shows unpushed diffs |
git diff origin/master..HEAD |
revert changes to modified files
remove all untracked files and directories
|
git reset --hard
git clean -fd
|
saves current changes in a "stash" (without committing them)
lists available stashes in a branch
reapply changes from stash@{0}
drops stash@{0}
|
git stash
git stash list
git stash apply stash@{0}
git stash drop stash@{0}
|
show the commit history
show the differences introduced in the last 2 commits
|
git log
git log -p -2
|
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.
|