How to stash my previous commit?

前端 未结 5 1823
感动是毒
感动是毒 2021-01-30 08:29

I\'ve got the following situation on my git log:

commit 111  <-- need to push it to the repository

commit 222  <-- need to stash this one

..         


        
5条回答
  •  你的背包
    2021-01-30 08:35

    If it were me, I would avoid any risky revision editing and do the following instead:

    1. Create a new branch on the SHA where 222 was committed, basically as a bookmark.

    2. Switch back to the main branch. In it, revert commit 222.

    3. Push all the commits that have been made, which will push commit 111 only, because 222 was reverted.

    4. Work on the branch from step #1 if needed. Merge from the trunk to it as needed to keep it up to date. I wouldn't bother with stash.

    When it's time for the changes in commit 222 to go in, that branch can be merged to trunk.

提交回复
热议问题