Git reset and rebase

Git reset
Some times we made many commit during PR , we want to combine them to one commit

We can see, I create 4 commits totally.

Git reset and rebase

1 backup the branch to remember the commit ID , in case that you did something wrong , you can roll-back.

$ git branch APPSOL-121312_local
Git reset and rebase

2 git branch -v . check the commit ID , the new branch has the same ID (b103a.....)

Git reset and rebase

3 git reset --soft commit ID( this commit ID is the one before your change, please check the first picture, 819f7 is checkout from master branch).

This command make all of your change combine together, and re-build a new commit ID.

Git reset and rebase

4 git status and git add ** and git diff --cached to see the change.

Git reset and rebase

5 git commit -m " massage"

Git reset and rebase

6 git push --force . (you must use --force) , other wise ,it will ask you to pull firstly. that will lead to conflict.

Git reset and rebase

上一篇:git rebase学习


下一篇:git rebase(变基)操作