GIT Aide Memoir

24 April 2016By Rich @Black Sand Solutions
  • Development
  • git

A place to keep commands I use often, but forget just as often.

GIT Aide Memoir

And also a place to keep a link to useful resources (https://try.github.io/levels/1/challenges/1, http://gitready.com/,http://pcottle.github.io/learnGitBranching/)

Remove Local Changes

If you want to revert changes made to your working copy, do this:

git checkout .

If you want to revert changes made to the index (i.e., that you have added), do this. Warning this will reset all of your unpushed commits to master!:

git reset

If you want to revert a change that you have committed, do this:

git revert ...

If you want to remove untracked files (e.g., new files, generated files):

git clean -f

Or untracked directories:

git clean -d

List Branches

git branch -a Lists all branches

git branch -r Lists remove branches

git for-each-ref --sort=-committerdate refs/heads/ lists the most recently worked on branches from top to bottom

Tools & Links

Generate gitingore files for common frameworks with
https://www.gitignore.io/

All Posts