Git invert staging area

后端 未结 4 1498
滥情空心
滥情空心 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:52

    Based on gtd's answer and the ability to script inverting the commits this is what I'm using now:

    [alias]                                                                                                                                                                                                              
        swaplast = !git tag _invert && git reset --hard HEAD~2 && git cherry-pick _invert _invert~1 && git tag -d _invert                                                                                            
        invertindex = !git commit -m tmp1 && git add -A && git commit -m tmp2 && git swaplast && git reset HEAD~1 && git reset HEAD~1 --soft
    

    Posted on my blog here: http://blog.ericwoodruff.me/2013/12/inverting-git-index.html

提交回复
热议问题