Skip to content

Commit

Permalink
Moved gitcheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
sidneyw committed May 26, 2016
1 parent c3678bd commit 17ab803
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions cheatsheets/git_cheatsheet
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
git status - view staged, unstaged, and untracked files
git commit - save staged snapshot to the git history

git log - view history
git log --author=<pattern>
- search for author
git log --grep=<pattern>
- search for commit message

git log --oneline
git log <file>
git log --graph --decorate

git checkout <branch|commit|file>
- Checking out a commit will not allow you to save any of the changes
- Checking out a file will put the checked out version of the file in the working
directory which can be committed

git revert <commit>
- Adds a negative commit to the history
- Can be undone

git revert HEAD
- undoes the last commit

git reset
- Resets the staging area which is different from revert
- Don't do this for published commits otherwise there will be a hole in the git
history

- Reset can be used to turn many local commits to a single commit

git reset
- Unstage all changes

git reset <HEAD|commit|file>
- Unstages a file but the changes are still there

git reset --hard <HEAD|commit|file>
- Reset the working directory to the last commit

git clean
- Deletes untracked files

git commit --amend
- Combines staged changes with the previous commit
- This alters the last commit without changing it
- Don't do this on published commits

git commit --amend --no-edit
- Ammend and don't change the commit message

0 comments on commit 17ab803

Please sign in to comment.