3205
голосов
9ответов
667506 просмотров

Move existing, uncommitted work to a new branch in Git

I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the existing uncommitted changes to a new branch and reset my current one? I want to reset my current branch while preserving existing work on the new feature.

3315
голосов
31ответов
2476618 просмотров

Delete commits from a branch in Git

I would like to know how to delete a commit. By delete, I mean it is as if I didn't make that commit, and when I do a push in the future, my changes will not push to the remote branch. I read git help, and I think the command I should use is git reset --hard HEAD. Is this correct?

1198
голосов
18ответов
454903 просмотров

Как отменить git reset --hard HEAD ~ 1?

Можно ли отменить изменения, вызванные следующей командой? Если да, то как? git reset --hard HEAD~1