What is git reset ?
If you are a developer or devops engineer, then this tutorial is going to be very useful for you. Here we will try to understand concept of git reset or you can say git revert and all related question like what does git revert, why we should use it and how many types of git revert.
Understand Git Reset
Git reset means to restore repository at a particular version. Let’s move a little bit deeper and take a real time scenario. Suppose we are working on a product and we have delivered 10 version to client of that product. Now client want a new feature.
Now developers have two options they can start coding from starting for new feature that will wastage of time and resource because already we have written our raw code. No need to write raw code again and again. Now second way is suppose up to 7 version of our raw code is same so we can reset our repository up to version 7 and can start work next. That will be easy and time saving.
Type of git reset
Mind it after restore point all commit id will delete. Our data or latest changes will delete or not it depend on type of reset. So, there are mainly three type of git reset.
Soft reset
In case of soft reset all commit id will delete after restore point but all latest changes or you can say data will remain as it is means data will not delete from latter on version from restore point. Let’s take an example suppose we have a repository with name test, and we have total 4 version into that repository.
As shown below figure. Suppose we want to reset this repository at version 2. When we will reset this repository at version 2 then after version 2 all commit will delete but changes of version 3 and 4 will remain as it is as before.
So now my question is when we should use soft reset. Let’s take a scenario suppose our commit id become more. Then more commit id will create confusion. But our all commit are tested and working fine so we can make final commit from all commit that will help to troubleshooting any issue easy. For better understanding go throw from below diagram once.
For more visit :-- [link removed]
Last edited by rtmistler; 11-07-2019 at 08:13 AM.
|