Skip to content

Instantly share code, notes, and snippets.

@josmithua
Created December 19, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josmithua/f8a091315f640da46149 to your computer and use it in GitHub Desktop.
Save josmithua/f8a091315f640da46149 to your computer and use it in GitHub Desktop.

GitHub Cheat Sheet for my Forgetful Mind

git remote add alias_name_for_remote repo_URL
git push -u alias_name_for_remote branch_name

git config --global alias.lol "log --oneline --graph --decorate --all"
git config --global alias.cm "commit -m"
git config --global alias.s "status"

git diff            // compares working directory and staged files
git diff --staged   // compares staged files with most recent commit
git diff HEAD       // combines working and staged files and compares with most recent commit
git diff --color-words // word by word comparison

git branch -d // delete branch. Must also delete GitHub branch

git log --stat  // tells you which files were included in each commit.
git log --patch // shows the actual changes that were made in each commit as diffs.

git mv old_file new_file_name_location

git revert [commit_hash] //revert particular commit
git commit --ammend //ammend last commit.

git reset HEAD file_name // unstage file

git reset --soft <my-branch> <other-commit> //leave staged and working untouched
git reset --mixed <my-branch> <other-commit> //leave working untouched
git reset --hard <my-branch> <other-commit> //revert everything. cannot undo!

can do:
git reset --soft <to_commit>
git reset --soft HEAD~<number>

git checkout --<filename> // revert file to what is was last commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment