- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在进行 merge/ rebase 时,我经常遇到这种情况: - 遇到一些冲突 - 解决重要的问题,将它们移动到索引
然后,有一堆未暂存的垃圾,我只想保留 HEAD 版本。理想情况下,我可以只执行“git commit && git reset --hard”,但 git 不会让我在仍有未 merge 的待处理内容时提交。我试过“git stash save --keep-index”但是失败了。我尝试了“git diff | patch -Rp1”(以及各种突变)。我认为任何“git reset”模式都不符合我的要求。
一定有一种方法可以说“我得到了我想要的,只需丢弃其余部分”。
最佳答案
没有开箱即用的解决方案,但您可以创建一个别名。
您可以使用:
git checkout HEAD -- <list of files to keep as HEAD>
指定您希望保留给定文件,因为它们在 HEAD
中。
要获取剩余冲突的列表,您可以使用:
git diff --name-only --diff-filter=U
然后将其作为别名放在一起:
alias gitkeeprest="for file in $(git diff --name-only --diff-filter=U); do git checkout HEAD -- $file; done"
有了它,您将:
gitkeeprest
将其余部分恢复为 HEAD
版本。关于Git merge : keep only the staged commits and toss the rest?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35108857/
有没有人在flutter中开发过像下面这样的动画?当我们点击那个添加到购物车的过渡动画时,我需要。让我知道是否有可用的插件。感谢您的帮助。 https://codepen.io/designcou
在进行 merge/ rebase 时,我经常遇到这种情况: - 遇到一些冲突 - 解决重要的问题,将它们移动到索引 然后,有一堆未暂存的垃圾,我只想保留 HEAD 版本。理想情况下,我可以只执行“g
我是 R 的新手,因此在这里提问(无法找到非常有用的详细模拟教程。) 问题陈述是这样的 模拟抛硬币 20 次并记录正面朝上的次数最长的正面。 模拟抛硬币并记录在连续(连续)出现 2、3、4 个正面(负
我正在尝试编写 Python 代码来查看平均需要掷多少次硬币才能连续出现 N 个正面朝上的序列。 让我感到困惑的是,我的代码生成的答案与在线给出的答案不匹配,例如这里(和许多其他地方)https://
我是一名优秀的程序员,十分优秀!