# Git (DevOps 5)

Hello everyone,

I am Batool Fatima. I am 18 years old. I have been learning DevOps for a month now. This is my fifth code blog. In last blog, I explained the concepts of branches, Git conflict and Git Stashing . Today, Let's learn about Git Reset, Git Revert and Tags with me.

## Git Reset-

Git Reset is the command we use when we want to move the repository back to a previous commit, discarding any changes made after that commit.

* To reset staging area we use- <mark>git reset &lt;filename&gt; git reset</mark>
    
* To reset the changes from both staging area and working directory at a time- <mark>git reset --hard</mark> (permanently delete)
    
* First, it's always worth noting that <mark>git reset --hard</mark> is a potentially dangerous command, since it throws away all your uncommitted changes. For safety, you should always check that the output of <mark>git status</mark> is clean (that is, empty) before using it.
    

## Git Revert-

The Git Revert command helps you undo an existing commit. It leaves the files in the same state as if the commit that has been reverted never existed.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1724480762372/38c6c292-1878-4e7c-9fec-911271c57d7e.png align="center")

* It does not delete any data in this process instead git creates a new commit with the included files reverted to their previous state.
    
* Your version control history moves forward while the state of your file moves backwards.
    
* We use <mark>git revert &lt;commit_id&gt;</mark> to revert our commit.
    
* A git revert is just another commit, so e.g. push to the remote so that other users can pull/fetch/merge the changes and you're done.
    

## Tags-

Tag option allows to give meaningful names to a specific version of the repository.

* You can create tags for GitHub by either using:
    
    * the Git command line, or
        
    * GitHub's web interface.
        
* To create a tag on your current branch, run this: <mark>git tag &lt;tagname&gt;</mark>
    
* To see the list of tags, run this: <mark>git tag</mark>
    
* To see a particular git commit by using tag, run this: <mark>git show &lt;tagname&gt;</mark>
    
* To delete a tag, run this: <mark>git tag -d &lt;tagname&gt;</mark>
    

So, This will be my last blog about Git and Soon I'll write more regarding DevOps from my next blog on some new topic.

Thank You!
