Pew Pew Laser Blog

Code. Glass art. Games. Baking. Cats. From Seattle, Washington and various sundry satellite locations.

Pew Pew Laser Blog Archives — by Blog ID

Git Tips - Commits and History.

11.12.2013

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 git stash
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:
  1. Save all changed, added and deleted files to the index
  2. Save that work into a magic "stash".
Now you can do whatever you need to do next, such as checkout another branch or switch projects. When you're ready to come back to your stashed work: 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 pop as used above just handles all of this for you.

Permalink

Tags: git

Authorized users may log-in to leave a comment.

Last Blog: Poxy Bowl, ca 2010.

Next Blog: A Persistent Case of Mis-Identification.