DEV Community

Discussion on: Git FAQs I Encounter Regularly

Collapse
 
edisonywh profile image
Edison Yap

Great tips here, to add on to top #3, instead of having to checkout into another new branch to retain your change, you can actually just do

git reset --soft head~1 (~1 being one commit, so obviously this varies)

Basically, --hard reverts your commits and discards your change, but whereas --soft reverts your commits but retains your change, so you can just checkout to another branch and commit there.

Collapse
 
3sanket3 profile image
Sanket Patel

That seems nicer approach. Will give a try. Thanks