![]() What if we wanted to go back to before that deletion? The first thing we need to know is some identifier for the commit we want to go back to. Last time we deleted both of the files in our repo. But, because I did not move the master branch (for now just think of it as another reference), it’s a very temporary change, easy to undo. If we change what commit HEAD points to, we change what the files in our repo look like. Changes made but not staged or committed.The version of them in the commit pointed to by HEAD.One way I think about it is that the files that I actually see in the repo are the sum of three things: Whichever commit HEAD points to is the one that the code in your working directory is based off of. That was a little white lie, really, the HEAD is a reference to some commit. In Lesson 3, we mentioned the HEAD as just the most recent commit. If we visualize the repo, it would look something like this: An animation showing the HEAD go back to commit number 2 from commit number 5, but the master branch does not move The easiest way is to just check out an old version of your code, temporarily. ![]() One natural guide you can use for when to commit is, Would I want to come back to this version of the code? If the answer is yes, commit! Method 1: temporarily check out an old commit That can help you decide how often to make commits. Something you will see in each case is that we can only bring a file back to where it was in a previous commit - there’s no way to go “halfway” between commits without some manual work. We’ll go through each one individually first, and then discuss the pros and cons of each at the end.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |