![]() The old file revision will show up as a “Change to be committed,” giving you the opportunity to revert back to the previous version of the file. ![]() Remember, unlike checking out a commit, this does affect the current state of your project. For example, if you only wanted to see the hello.py file from the old commit, you could use the following command: git checkout a1e8fb5 hello.py If you’re only interested in a single file, you can also use git checkout to fetch an old version of it. To continue developing, you need to get back to the “current” state of your project (assuming your master branch is the head of the project): git checkout master It’s impossible to harm your repository while viewing an old revision. Checking out an old commit is a read-only operation. Nothing you do in here will be saved in your repository. You can look at files, and even edit files without worrying about losing the current state of the project. This makes your working directory match the exact state of the a1e8fb5 commit. You can use git checkout to view the “Make some import changes to hello.py” commit as follows: git checkout a1e8fb5 (This will put you in a detached HEAD state.) Checking out a file lets you see an old version of that particular file, leaving the rest of your working directory untouched. This can be used to view an old state of your project without altering your current state in any way. Checking out a commit makes the entire working directory match that commit. In this part, only the first two configurations are addressed. ![]() The git checkout command serves three distinct functions: checking out files, checking out commits, and checking out branches. git log -onelineĮxample output b7119f2 Continue doing crazy thingsĪ1e8fb5 Make some important changes to hello.py No worries, erroneous commits can be undone or reverted.įirst, check your history of commits to see which commits are the faulty ones. You notice you have done something wrong on your branch. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |