I’ve been following a tutorial on Git and I’m a bit confused about a few specific issues. The main reason I need to use version control right now is simply to access previous versions of my project if I make a mistake and don’t know how to get rid of an error.
-
Is it true that a version is only saved in Git if you executed a commit statement? For some reason, I was thinking that every time you make any change in your project it would automatically be added as a version in your repository for you to go back to.
-
So when should you execute commit? Is it only when you think you’ve made a good bit of progress?
-
How do you actually revert to a previous version in Git? i.e. what’s the command?
1. With Git (same with SVN, or Bazzar, or others), you need to commit so a version is saved — this way, git only keeps track of the versions you considered as good enough.
2. I tend to commit when I’ve got something that works OK — at least when working on the main branch.
If I’m working on a temporary branch, created specifically to develop a new feature / fix a bug, then I commit pretty much whenever I want, to save the current state of my work.
3. You should take a look at the following page : Undoing in Git – Reset, Checkout and Revert