Getting started with GIT – Part 5
This is the 5th part of the getting started with GIT tutorial series. Here we will explorer some most important functions of GIT. This is a continuation from the last part "Getting started with GIT – Part 4".
Lets see how to get old version of our project.
- Currently my website looks like this.
- Now I am going add another main content area to my website. And commit those changes to the repository.
- And again, I am going to add another(fourth) main content are to my website and commit those changes.
- Now website looks like this.
- So, we assume we only need 3 main content blocks and we want to go back to the commit where we had only 3 main content blocks.
- We can achieve it by checkout the version with only 3 content areas. So, we can use command “git checkout <commit number> -- <the file name>”. So, what we are saying to git is go to this commit with given commit number and get a copy of the file index.html. Here we don’t need to type whole commit number. Entering first few characters will do the work. To know the commit number of each commit you can view all commits using “git log” command.
- If you now check status it says you have a different version from the repository. Actually, that is what we want.
- Now we have the version we wanted to have in our working copy.
- So, if I refresh my website you can see that we are back to the point where there is only 3 main content blocks.
- Last step we have to do is committing the current working copy to the repository.
Its the end for this part. In the next part i am planning to explore functions delivered by GITHUB. Have a good one with GIT :)
Comments
Post a Comment