GIT Version Control System

GIT Version Control System

Today we are going to see how to reset our files and directory. 

Imagine this. You open your project directory and fix some mistakes many times.  Finally, if the output is not what you expected, how do you go to the Past project directory? Let’s see.

If the changing file is in the staging area. How to remove that change only in the staging area?

 

This is our previous directory:

After the changing: Color changing

 

Imagine we add this change in the staging area.

 

But we don’t like this change. Anyhow, how to go to our past directory?

  • Only removing from staging area:

git reset HEAD

 

 

  •  Removing from the working directory also.

git reset HEAD –hard

 

In the above image, you can see changes removed from the working directory. I hope you can understand the difference between git reset HEAD and git reset HEAD – hard.

By these commands you only remove bugs. If you need to remove a folder or files how to do that? Let’s see.

In the above statement, you have to modify some files and add one untracked file in the staging area. But now you think you don’t need this sass folder and its files. How to remove that?

git clean -fd                  

or

git clean -f -d

 

 

Note:  So, if we need to discard unsuccessful changes you can use these commands:

 git reset HEAD –hard
git reset HEAD
git clean –fd

I hope this is useful for beginners to understand what is reset in git.  If you want to interested in watching more videos about git. Please watch Appslanka git videos on our youtube channel. https://www.youtube.com/playlist?list=PLZmKantulzuSeqMy-zM56ZC0S7watreeu. Don't forget to subscribe.

0 Comments

Leave a comment

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