有没有一种方法可以预先为git rebase提供列表以用于rebase [英] Is there a way to presupply git rebase with the list to use for rebase

查看:54
本文介绍了有没有一种方法可以预先为git rebase提供列表以用于rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代替 git rebase -i 并手动编辑,可以将 git rebase 的拾取/删除/压扁列表作为文本文件提供,还是我可以是否需要将GIT_EDITOR重定向到提供它的脚本?

Instead of git rebase -i and editing manually is there a possibility to supply git rebase with the pick/drop/squash list as a text file, or do I need to redirect GIT_EDITOR to a script that supplies it ?

推荐答案

您需要使用 GIT_EDITOR GIT_SEQUENCE_EDITOR 来就地编辑文件.该程序将接收文件名作为其参数,并且可以是一个shell命令,因此您可以执行以下操作:

You'll need to use GIT_EDITOR or GIT_SEQUENCE_EDITOR to edit the file in place. That program will receive the file name as its argument, and can be a shell command, so you can do something like this:

GIT_SEQUENCE_EDITOR='sed -i -e '\''2,$s/^pick/fixup/'\' git rebase

两个编辑器之间的区别在于, GIT_SEQUENCE_EDITOR 仅适用于rebase待办事项列表,而不适用于诸如提交消息之类的其他事物,而 GIT_EDITOR 则适用于两者.因此,例如,如果您想自动压缩由 git commit --squash git commit --fixup 创建的所有南瓜提交和修正提交,而无需提示,这个:

The difference between the two editors is that GIT_SEQUENCE_EDITOR only applies to the rebase todo list, but not to other things like commit messages, whereas GIT_EDITOR applies to both. So, for example, if you want to automatically squash in all squash and fixup commits created by git commit --squash and git commit --fixup without prompting, you can do this:

GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash main

这会自动接受squash和fixup命令,而不会提示您,但由于squash提交,仍然使您的普通编辑器可以编辑提交消息.

That automatically accepts the squash and fixup commands without prompting, but still leaves your normal editor for editing commit messages due to squash commits.

这篇关于有没有一种方法可以预先为git rebase提供列表以用于rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆