Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
挤压GitHub中pull请求中的提交,git rebase未打开我的文本编辑器_Git_Github - Fatal编程技术网

挤压GitHub中pull请求中的提交,git rebase未打开我的文本编辑器

挤压GitHub中pull请求中的提交,git rebase未打开我的文本编辑器,git,github,Git,Github,我正在尝试将我的最后4次提交合并为一次(提交已经在GitHub上的pull请求中) 我已使用以下设置了默认编辑器: git config --global core.editor "'C:\Program Files\Sublime Text 3\sublime_text.exe' -w" 我没有收到确认消息(我应该吗?),我使用的是Windows 8 然后,我尝试重新设定基准: git rebase -i HEAD~4 我得到了以下信息: Successfully rebased and

我正在尝试将我的最后4次提交合并为一次(提交已经在GitHub上的pull请求中)

我已使用以下设置了默认编辑器:

git config --global core.editor "'C:\Program Files\Sublime Text 3\sublime_text.exe' -w"
我没有收到确认消息(我应该吗?),我使用的是Windows 8

然后,我尝试重新设定基准:

git rebase -i HEAD~4
我得到了以下信息:

Successfully rebased and updated refs/heads/name-of-my-branch
我认为文本编辑器应该随着我的提交而打开,我可以选择
拾取
挤压

有人能给我一个关于如何在Windows命令提示符下使用Git将4个提交合并/压缩为1的分步回答吗


谢谢

使用命令检查分支中的提交

$ git log --oneline
你会得到这样的结果

f0d5199 changes in end points
a4cb008 changes
2e1f2c2 Ui Changes
d70542c Text changes
cb3c304 remove file
您希望sqaush最后4次提交,即(f0d5199、a4cb008、2e1f2c2、d70542c) 并使其单次提交

现在进行第五次提交,即cb3c304并使用命令

$ git rebase -i cb3c304
默认编辑器将像vim、nano一样打开。就我而言,它表现得像

pick d70542c Text changes
pick 2e1f2c2 Ui Changes
pick a4cb008 changes
pick f0d5199 changes in end points

# Rebase cb3c304..f0d5199 onto cb3c304 (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
现在,您可以根据自己的选择选择选择或挤压提交,如

pick d70542c Text changes
s 2e1f2c2 Ui Changes
s a4cb008 changes
s f0d5199 changes in end points
更改了3提交(sha)“选择s”并保存,编辑器将再次打开,再次保存。新的sha(提交id)已创建51c2b3b,并显示“文本更改”消息

现在,所有4个提交更改将在一个提交中完成,即(sha 51c2b3b)

压扁完成了。现在检查日志

$ git log --oneline

51c2b3b Text changes
在谷歌上搜索“core.editor sublime”,我发现可能的解决方案如下:

git config --global core.editor "subl -n -w"

我不知道如何在Windows上解决这个问题,但我怀疑这是
core.editor
字符串的引用问题。设置值时不应收到确认消息,但您肯定应该有机会在编辑器中编辑重基计划。我会尝试直接编辑你的
~/.gitconfig
文件,至少从图片中删除一级shell引用。感谢你的回复,由于某种原因,它挂在了“记事本”上,我实际上不得不在Git->usr->bin文件夹中将我的vim重命名为“notepad”,以欺骗它至少打开vim。即使将~/.gitconfig中的路径更改为vim或其他任何东西也不起作用。现在可以了,但这是一个非常奇怪的解决方案。