Reset,Revert and Delete files in Local Repository

Share via:

Reset,Revert and Delete files in Local Repository

In this article,we will see Reset,Revert files in Local Repository.

Implementation Steps

  1. Delete Snapshot from Staging Area.
  2. Delete file from both areas (Staging Area & Work Space).
  3. Remove specific file from workspace.
  4. Delete All untracked files.

Git Reset

Delete Snapshot from Staging Area

Create a new file “ktexperts-reset”

To see the status of git

Adding file to Staging Area

Delete the snapshot from staging area by using reset command

Git Reset 

Delete file from both areas (Staging Area & Work Space)

To see the status of git

Adding file to Staging Area

To see the status of git

Delete file from both areas (Staging Area & Work Space) by using reset –hard command.

To see the list of files

Here,we unable to see the file “ktexperts-reset” because we have done the reset–hard recently.

If you do the reset–hard,the file will be deleted from staging area and work space.

To see the current branch

Git Revert

Revert to a existing commit

Create a new file “ktexperts-Revert”

Add and commit the file “ktexperts-revert”

To see the status of git

Adding file to Staging Area

Commit the file into Local Repository

To see the latest commit

To see the all commits in a summarized manner

To do the revert changes by using revert command

To see the all commits in a summarized manner

To see the list of files

Here,we can’t see the file “ktexperts-revert”.

If you do the revert of any file,that will delete the file from staging area and workspace.

Revert will create a new commit ID.

You need not to add and commit again. (Automatically new commit ID will be generated).

Git rm

Remove specific file from workspace

Note

The file will be deleted from staging area as well as workspace.

The commit ID won’t get deleted.

To see the list of files

 

To see the status of git

Commit the deleted file into Local Repository

Git Clean

Delete All untracked files

Create a new empty files

By using touch command

To see the status of git

To show the confirmation message to delete untracked files

To see the status of git

To Delete all untracked files forcefully by using clean -f command.

To see the status of git

To see the list of files


Tag

It is a meaning full name.

Whenever you commit, you will get one commit ID.

This commit ID contains 41 alphanumeric characters, so we can’t remember commit ID.

we can’t remember commit ID for that we use tag to pick the data of commit ID.

For easier understanding we give tag for the commit ID.

Create a new file “ktexperts-tag”

Add and commit the file “ktexperts-tag”

Adding file to Staging Area

Commit the file into Local Repository

To see the list of commits in a summarized manner

Assign Tag to Particular Commit ID

To see the list of commits in a summarized manner

To show the data of commit ID by using tag

To remove the tag from Commit ID

To see the list of commits in a summarized manner

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTEXPERTS is always active on below social media platforms.

Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform

 

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...

2 thoughts on “Reset,Revert and Delete files in Local Repository

Add Comment