GIT RESET

GIT RESET:-

If git revert is a “safe” way to undo changes, you can think of git reset as the dangerous method. When you undo with git reset(and the commits are no longer referenced by any ref or the reflog), there is no way to retrieve the original copy—it is a permanent undo. Care must be taken when using this tool, as it’s one of the only Git commands that has the potential to lose your work.

#Remove the specified file from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.
git reset 

#Reset the staging area to match the most recent commit, but leave the working directory unchanged. This unstages all files without overwriting any changes, giving you the opportunity to re-build the staged snapshot from scratch.
git reset

#Reset the staging area and the working directory to match the most recent commit.
git reset --hard

#Move the current branch tip backward to , reset the staging area to match, but leave the working directory alone. All changes made since  will reside in the working directory, which lets you re-commit the project history using cleaner
git reset 

#Move the current branch tip backward to  and reset both the staging area and the working directory to match. 
git reset --hard 

Leave a Reply

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