Git invert staging area

后端 未结 4 1511
滥情空心
滥情空心 2021-02-13 16:14

I have got changes in my staging area, and others not staged yet (some files have changes both in and out the staging area). I would like to invert the content of the st

4条回答
  •  佛祖请我去吃肉
    2021-02-13 16:59

    Here’s how I do it:

    1. Commit the index to a temporary commit
    2. Commit the remainder to a secondary temporary commit
    3. Switch the order of the commits with interactive rebase
    4. Mixed reset
    5. Soft reset

    It can be typed out manually pretty fast, especially if you use Vim for commit messages:

    git commit -m tmp1
    git add . # optionally with `git add -u` if there are deletions
    git commit -m tmp2
    git rebase -i HEAD~2 # swap the order of the commits; `ddp:wq` in vi
    git reset HEAD~1
    git reset HEAD~1 --soft
    

提交回复
热议问题