reset vs checkout

First I need to say, I understand the terminologies as

work directory: your current source code

stage: a cache copy of the code; "commit" usually are from this cache

commits: more officially history records of your previous code and those records are made through your "git commit" commands

 

 

Each branch has a tip pointer like "master","development". When you do

it moves the current pointer (unfortunately, this pointer is called "HEAD") to the branch tip of <branch_name>. This changes show up in your work tree (which refers to your real coding files).

Similarly, the following command will bring your code back to a previous specified time point.

As you still have all your commits, you can revert your coding files back to the another branch tip namely the <branch_name>.

However, this is different for git reset

reset, will move the tip pointer <branch_name> to <to_point>., whose default value is HEAD (current position).

Then you lost all the commits between <to_point> and the "old" <branch_name>.

--soft-- means change the commits only,

--mix-- (default) change both commits and stage, but leave your current source code untouched

--hard--change everything and you will have no way to revert this change

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *