Git翻转暂存区 [英] Git invert staging area
本文介绍了Git翻转暂存区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的临时区域发生了变化,还有一些没有暂停(有些文件在暂存区域内外都有变化)。 我想倒转暂存区域的内容和未暂存的更改。为了做到这一点,是否存在快捷方式,而不需要执行更复杂的操作,如本地侧分支提交,差异或存储等[]。感谢。
解决方案
以下是我的工作方式:
- 将索引提交给临时提交
- 将其余部分提交到辅助临时提交
- 切换提交顺序rebase
- 复合复位
- 软复位
它可以手工输入很快,特别是如果你使用Vim提交消息:
提交-m tmp1git add。 #可选用`git add -u`(如果有删除)
git commit -m tmp2
git rebase -i HEAD〜2#交换提交顺序; vi中的`ddp:wq` b $ b git reset HEAD〜1
git reset HEAD〜1 --soft
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 staging area and the changes which are not staged. Does a shortcut exist in order to do that, without doing more complex actions like local side-branch commits, or diffs, or stashes [etc.]? Thanks.
解决方案
Here’s how I do it:
- Commit the index to a temporary commit
- Commit the remainder to a secondary temporary commit
- Switch the order of the commits with interactive rebase
- Mixed reset
- 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
这篇关于Git翻转暂存区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文