在变基期间,我经常希望查看当前正在应用的提交的消息,以帮助理解合并冲突。
我曾经跑过:
$ cat .git/rebase-apply/message
Run Code Online (Sandbox Code Playgroud)
这会给我很好的。但是,在我运行 git v2.20.1 的新机器上,该文件在变基期间不再存在。
我在哪里可以获得当前正在应用的提交的消息(当变基因合并冲突而暂停时)?
TL;DR:检查您git rev-parse --git-path rebase-merge/message是否git rev-parse --git-path rebase-apply/msg位于添加的工作树中。
不幸的是,获取此信息的接口并不稳定。然而,您正在寻找的文件仍然存在于现代 Git 中。
\n\n随着 的出现git worktree,大多数状态信息已经(至少可能)发生了变化。现在存在相同类型的文件,但位置不同。要查找 git 相对路径名为P的文件的位置,请使用:git rev-parse --git-path P
$ git rev-parse --git-path HEAD\n.git/HEAD\n$ git worktree add ../git2 --detach\nPreparing worktree (detached HEAD 5d826e9729)\nHEAD is now at 5d826e9729 Git 2.20\n$ (cd ../git2; git rev-parse --git-path HEAD)\n[redacted]/git/.git/worktrees/git2/HEAD\nRun Code Online (Sandbox Code Playgroud)\n\n从 Git 2.13 开始,可以找到 rebase 信息的两个目录是:
\n\nrebase-apply\nrebase-merge\nRun Code Online (Sandbox Code Playgroud)\n\n(一如既往,使用 git-path 技巧来定位实际目录或其中的单个文件)。其中的文件最初是对称的,因为代码只是设置一个状态目录,然后根据需要将文件放入其中。在未来的任何 Git 版本中,该文件集可能会发生变化;然而,由于. contrib/completion/git-prompt.sh首先查看内部rebase-merge(如果存在):
head-name the branch you were on when you started the rebase\nmsgnum how many commits are already done (how far along are you)\nend the total number of commits to do\ninteractive if exists, means this is git rebase -i (vs git rebase -m)\nRun Code Online (Sandbox Code Playgroud)\n\n如果rebase-merge不存在,它会在内部rebase-apply(如果存在)查找:
next how many commits are already done (how far along are you)\nlast the total number of commits to do\nrebasing if exists, means this is an ordinary git rebase, in which case:\n head-name the branch you were on when you started rebasing\napplying if exists, means this is a git am without rebase\nRun Code Online (Sandbox Code Playgroud)\n\n如果变基文件和应用文件都不存在,则提示代码假定“git-am 或 git-rebase”,而不会尝试进一步猜测任何内容。
\n\n如果两个目录都不存在,则提示设置代码将继续检查:
\n\nMERGE_HEAD a merge is in progress\nCHERRY_PICK_HEAD a cherry-pick is in progress\nREVERT_HEAD a revert is in progress\nBISECT_LOG a bisect is in progress\nRun Code Online (Sandbox Code Playgroud)\n\n序列发生器代码(现在用于除遗留 rebase 之外的所有代码,尽管我不确定它在 2.13 中使用了多少)比其中任何一个都不太稳定,它还有更多\xe2\x80\x94查看中的GIT_PATH_FUNC所有行源代码。其中之一就是您的rebase-merge/message文件。无论您正在执行交互式变基、 、git rebase -m或,此文件都应该存在于适当的工作树相关路径中。我认为,对于非交互式文件应该位于其中。git rebase -s strategygit rebaserebase-apply/msg
| 归档时间: |
|
| 查看次数: |
655 次 |
| 最近记录: |