remove the last commit git without losing changes

Shell
git reset HEAD~1 --soft   
Source

Also in Shell: