Wednesday, March 8, 2017

GIT Resets


GIT REST HELP
  • Soft
    • git reset --soft <commit id>
  • Mixed
    • git reset --mixed <commit id>
  • Hard
    • git reset --hard <commit id>

Check git log status:
git log --oneline

Soft:
git reset --soft <commit id>

Result:
Brings the files changed after this commit id into staging index. 
i.e, as if those changed files were added using git add command.

Mixed:
git reset --mixed <commit id>

Result:
Brings the files changed after this commit id into Working Directory. 
i.e, as if those changed files were changed but not gone through git add yet.

Hard:
git reset --hard <commit id>

This is the most dangerous command as it is going to completely wipe out our working directory and staging index. Any files you were tinkering with will be gone.

Result:
Brings the files changed after this commit id into staging index. 
i.e, as if those changed files were added using git add command.


git reset --hard HEAD
This will bring your code base to the commit where HEAD is pointing to.
Basically this will wipe out any changes in Working Directory and Staging Index.


TODO:
Pushing reset commit to remote?

No comments:

Post a Comment