Question

Sorry, but this trio of git commands is taxing my intelligence.

Is it possible to set up a group wiki for total newbies to cover these three git commands? What I am trying to learn is how to restore or rollback files and projects to a prior state.

As I have no experience with subversion or other centralized version control software, reference to how they did things differently is unnecessary and often confusing.

Thanks.

Was it helpful?

Solution

All the resources you mentioned are quite popular, and I'm surprised you didn't find them helpful. The man pages for each of those commands are probably the most descriptive resource, but are admittedly dry and dense. Here is a brief summary of the difference between the three commands:

  • git revert takes a treeish and creates a new commit undoing the changes made in the given commit

  • git checkout does just that: checks out a treeish. If you pass a branch name, you'll move to the HEAD of that branch, if you pass a non-HEAD commit or tag, you'll enter a "detached HEAD" state. Regardless, your working tree will now be the same as it was at the commit (there are some edge cases here with untracked/new files).

  • git reset takes a treeish, and erases all the commits up to (but not including) the given commit, but without altering the current state of any of the files. That is, the commits are gone, but your working tree remains in the same state. Passing --hard also puts the files back to the state.

(Yes, a treeish is a real thing)

OTHER TIPS

Is it possible to set up a group wiki for total newbies to cover these three git commands?

Honestly? Probably, yeah. Definitely, maybe. I've never set up a wiki, though, so I don't know if I'd be able to help you. :P

In all seriousness, though, this link might help you if you haven't seen it before: http://wiki.freegeek.org/index.php/Git_for_dummies

Additionally, check out this question if you haven't parsed it already: Git for beginners: The definitive practical guide

http://progit.org/2011/07/11/reset.html helped me a lot in seeing the similarities and differences between checkout and reset. Revert is a different story that creates a new commit, canceling out another.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top