Skip to content

Instantly share code, notes, and snippets.

@RedSoxFan22
Last active August 29, 2015 14:23
Show Gist options
  • Save RedSoxFan22/ca35bb0a8341415cccfa to your computer and use it in GitHub Desktop.
Save RedSoxFan22/ca35bb0a8341415cccfa to your computer and use it in GitHub Desktop.
What command do you run if you want to discard all changes since your last commit? git checkout . There are three areas inside a repo: working directory(atom file), staging area, repository. Git checout takes what was in the repository and wipes it out. Git stash saves what you've done but removes them from the working directory.
Git stash pop: to get it out of the stack
Only use git stash if you want to get your code back.
Git reset --hard HEAD: HEAD is the last thing in the repository. Git reset hard is take the state of the repo and copy HEAD to staging area and working directory, and override the HEAD in those parts. -hard pulls it back 2 steaps. -mix and -soft as well
What command do you use if you run git add and then want to revert it? git reset --hard HEAD (HEAD is optional)
What command do you use if you run git commit and then want to revert it? git reset --hard HEAD ~1 (takes you back one step in time. any number will work. git revert won't work because it creates a new commit, but doesn't delete the last commit. All the points in time stil exist with git revert.
What command do you use if you run git push and then want to revert it? git revert and push up changes again.
OR git filter-branch (the nuclear option).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment