当我开始时git rebase -i,我可以发出像git rebase --continue或的命令git rebase --abort.这些命令仅在rebase正在进行时才有效.
我如何知道是否有正在进行的改造?
(我非常感谢关于rebase如何在内部工作的一些细节; git对一个repo做了什么,使它具有"rebase in progress"状态,?)
Von*_*onC 51
首先,在rebase期间有一个ORIG_HEAD适当的位置(但不限于rebase命令)
但是你也可以看一下2010 Git 1.7.0 git-rebase.sh脚本本身(你可以得到"内部";)).
像这样的线可以给你另一个线索:
dotest="$GIT_DIR"/rebase-merge
test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || die "No rebase in progress?"
Run Code Online (Sandbox Code Playgroud)
rebase-apply似乎出现rebase,rebase-merge只显示with rebase -i.编码指南不鼓励使用
-o(参见参考资料Documentation/CodingGuidelines),所以现在正确的方法(2017年,自2011年以来,Git 1.7.6)是:
(test -d ".git/rebase-merge" || test -d ".git/rebase-apply") || die "No rebase in progress?"
Run Code Online (Sandbox Code Playgroud)
(test -d "$(git rev-parse --git-path rebase-merge)" || \
test -d "$(git rev-parse --git-path rebase-apply)" )
Run Code Online (Sandbox Code Playgroud)
这可以正确处理没有
.git目录的工作树和异常或非标准布局,还允许您从工作目录的子目录运行此测试.
那是因为git rev-parse --git-path <path>:确实解决了" $GIT_DIR/<path>".
Git 2.6 +(2015年第3季度)将在rebase期间打印更多信息:
请参阅提交592e412,提交84e6fb9(2015年7月6日),提交84e6fb9(2015年7月6日),并提交由GuillaumePagès()提交df25e94,提交05eb563(2015年6月30日).(由Junio C Hamano合并- -在提交178d2c7,2015年8月3日)gitster
gitster
status:提供更多信息rebase -i
git status提供有关在rebase -irebase期间完成的命令列表的更多信息.
它显示:
- 最后两个命令执行和
- 接下来要执行的两行.
它还提供了查找
.git目录中的整个文件的提示.
Jak*_*ski 16
您还可以检查__git_ps1函数中的contrib/completion/git-prompt.sh这种检测是如何完成的,可以用于git-aware bash提示:
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
else
if [ -d "$g/rebase-apply" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
Run Code Online (Sandbox Code Playgroud)
这里有一些不好的答案。git并没有真正说明它应该如何工作,所以唯一的答案是“git 是如何做到的?”。代码在这里:
int wt_status_check_rebase(const struct worktree *wt,
struct wt_status_state *state)
{
struct stat st;
if (!stat(worktree_git_path(wt, "rebase-apply"), &st)) {
if (!stat(worktree_git_path(wt, "rebase-apply/applying"), &st)) {
state->am_in_progress = 1;
if (!stat(worktree_git_path(wt, "rebase-apply/patch"), &st) && !st.st_size)
state->am_empty_patch = 1;
} else {
state->rebase_in_progress = 1;
state->branch = get_branch(wt, "rebase-apply/head-name");
state->onto = get_branch(wt, "rebase-apply/onto");
}
} else if (!stat(worktree_git_path(wt, "rebase-merge"), &st)) {
if (!stat(worktree_git_path(wt, "rebase-merge/interactive"), &st))
state->rebase_interactive_in_progress = 1;
else
state->rebase_in_progress = 1;
state->branch = get_branch(wt, "rebase-merge/head-name");
state->onto = get_branch(wt, "rebase-merge/onto");
} else
return 0;
return 1;
}
Run Code Online (Sandbox Code Playgroud)
它基本上检查这几个文件/目录是否存在(注意!stat()意味着“文件是否存在”)。am这git am是用于从邮箱应用补丁的,我怀疑除了 Linux 开发人员之外没有人使用它。
rebase_in_progress:.git/rebase-apply && !.git/rebase-apply/applying || .git/rebase-merge && !.git/rebase-merge/interactiveinteractive_rebase_in_progress:.git/rebase-merge && .git/rebase-merge/interactiveam_in_progress:.git/rebase-apply && .git/rebase-apply/applying我想如果你想知道是否发生任何类型的 rebase/am,只需检查是否.git/rebase-apply存在.git/rebase-merge。
| 归档时间: |
|
| 查看次数: |
20996 次 |
| 最近记录: |