☯︎ Li

Reverting changes in git

Revert changes from working directory

git restore <file_name> 
        or
git checkout -- <file_name>

Note: even we can remove changes manually. But if we have updated multiple files and don’t know which lines to remove this command really helps

Revert changes from Staging Area

#To revert changes from Staging area
git restore --staged <file_name>  to working directory  

#To revert changes from working directory  
git restore <file_name> 

Revert changes from Local Repository

#To revert changes from local repo to working directory directory
git reset HEAD~  

#To revert changes from working directory
git restore <file_name(s)>   

Revert changes from Remote Repository

We dont have direct way to do this.

#git