Git Tips - Commits and History.
Here are a few things for working with commits and previous file versions.
git add -A
git revert [sha]
- The above block is 2 sequential git commands. First, add all file changes to Git's watchlist. Roll back to the previous commit, throwing away all changes that you haven't yet committed.
git checkout -b [branch-name] [sha]
- Check out an old commit to a new branch so that you can fiddle with it.
git checkout origin/master -- [file]
- Replace the current working directory version of that file with the one from master. This is great for reverting a bunch of changes.
git add -A
- These two commands which will allow you to save your work in the middle of a commit, and come back to it later. In detail:
- Save all changed, added and deleted files to the index
- Save that work into a magic "stash".
git stash pop
git stash list
- List all of the stuff you've previously stashed.
git stash apply --index
- Applies your most recently stashed work back to your working index. You must also
git stash drop [stash name]to remove that particular stash from the list of stashed stuff.
git stash popas used above just handles all of this for you.