当我做一个互动的rebase,例如
git rebase -i HEAD~3
Run Code Online (Sandbox Code Playgroud)
rebase交互式编辑器(在我的情况下为vim)打开,让我编辑提交到rebase
pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbcopy` (OS X)
....
Run Code Online (Sandbox Code Playgroud)
如果我现在决定我要中止rebase并且:q仍然使用rebase启动退出vim .我1.9.0.msysgit.0在Windows上使用git版本.
当然我可以删除所有pick行,但如果我更长历史可能会有很多事情要做.还有另外一种方法吗?
如何退出rebase交互式编辑器(vim)并中止rebase?
我试图为解释编辑旧提交信息在这里.
问题是,现在,当我试图运行rebase -i HEAD~5时说interactive rebase already started.
所以然后我尝试:git rebase --continue但是得到了这个错误:
error: Ref refs/heads/master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba
fatal: Cannot lock the ref 'refs/heads/master'.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我们有一个拥有超过400个提交的Git存储库,其中前几个是很多试错.我们希望通过将许多提交压缩到单个提交来清理这些提交.当然,git-rebase似乎还有很长的路要走.我的问题是它最终会出现合并冲突,而这些冲突并不容易解决.我不明白为什么会有任何冲突,因为我只是压缩提交(不删除或重新排列).很可能,这表明我并不完全理解git-rebase是如何做它的南瓜的.
这是我正在使用的脚本的修改版本:
repo_squash.sh(这是实际运行的脚本):
rm -rf repo_squash
git clone repo repo_squash
cd repo_squash/
GIT_EDITOR=../repo_squash_helper.sh git rebase --strategy theirs -i bd6a09a484b8230d0810e6689cf08a24f26f287a
Run Code Online (Sandbox Code Playgroud)
repo_squash_helper.sh(此脚本仅由repo_squash.sh使用):
if grep -q "pick " $1
then
# cp $1 ../repo_squash_history.txt
# emacs -nw $1
sed -f ../repo_squash_list.txt < $1 > $1.tmp
mv $1.tmp $1
else
if grep -q "initial import" $1
then
cp ../repo_squash_new_message1.txt $1
elif grep -q "fixing bad import" $1
then
cp ../repo_squash_new_message2.txt $1
else
emacs -nw $1
fi
fi
Run Code Online (Sandbox Code Playgroud)
repo_squash_list.txt :(此文件仅由repo_squash_helper.sh使用)
# Initial import
s/pick \(251a190\)/squash …Run Code Online (Sandbox Code Playgroud) I managed to create a little mess in my local git repository. I was trying to fix a broken commit by using the following instructions. Before running the "git commit --amend" (and after the git rebase --interactive) I decided that my changes were incorrect and so I executed "git reset HEAD --hard". Not a good idea, I tell you.
现在,交互式基础似乎被"卡住了".Git将当前分支显示为(| REBASE-m).我的存储库中的每个命令(cd ..,ls,git rebase ...)都会出现以下错误:
cat:.git/rebase-merge/head-name:没有这样的文件或目录
以下是git rebase --abort的样子:
$ git rebase --abort
cat: c:/_work/project/src/git/.git/rebase-merge/quiet: No such file or directory …Run Code Online (Sandbox Code Playgroud) 我们使用git并拥有一个主分支和开发人员分支.我需要添加一个新功能,然后将提交重新设置为master,然后将master推送到CI服务器.
问题是,如果我在rebase期间遇到冲突,我不能在rebase完成后推送到我的远程开发人员分支(在Github上),直到我拉出我的远程分支.这会导致重复提交.没有冲突时,按预期工作.
问题:在rebase和冲突解决之后,如何在不创建重复提交的情况下同步我的本地和远程开发人员分支
建立:
// master branch is the main branch
git checkout master
git checkout -b myNewFeature
// I will work on this at work and at home
git push origin myNewFeature
// work work work on myNewFeature
// master branch has been updated and will conflict with myNewFeature
git pull --rebase origin master
// we have conflicts
// solve conflict
git rebase --continue
//repeat until rebase is complete
git push origin myNewFeature
//ERROR
error: failed to push some …Run Code Online (Sandbox Code Playgroud) 当我跑:
git status
Run Code Online (Sandbox Code Playgroud)
我看到了这个:
rebase in progress; onto 9c168a5
You are currently rebasing branch 'master' on '9c168a5'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
当我做:
ls `git rev-parse --git-dir` | grep rebase || echo no rebase
Run Code Online (Sandbox Code Playgroud)
我明白了:rebase-apply
我不能承诺起源.
git branch
Run Code Online (Sandbox Code Playgroud)
显示:
* (no branch, rebasing master)
develop
master
Run Code Online (Sandbox Code Playgroud)
我被卡住了.我不知道该怎么办?是否真的需要这么长时间才能改变?git rebase --continue什么都不做 我没有任何git状态..我只是在等待rebase.我能做什么?
UDATE:这是输出:git rebase --continue
Applying: no message
No changes - did you forget to use 'git add'?
If there is nothing …Run Code Online (Sandbox Code Playgroud) 我正试图改变'dev'以赶上'master'分支.
$ git checkout dev
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Corrected compilation problems that came from conversion from SVN.
Using index info to reconstruct a base tree...
M src/com/....
<stdin>:125: trailing whitespace.
/**
<stdin>:126: trailing whitespace.
*
<stdin>:127: trailing whitespace.
*/
<stdin>:128: trailing whitespace.
package com....
<stdin>:129: trailing whitespace.
warning: squelched 117 whitespace errors
warning: 122 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging …Run Code Online (Sandbox Code Playgroud) 这是我的脚本,试图将我的bugfix分支合并到我的主分支上,准备将其推向上游.自bugfix分支创建以来,已经有一些上游更改被拉入master,现在它拒绝rebase.
它抛出错误的文件在打开时不会被分散.没有添加,删除或重命名的文件.没有任何东西被忽略,没有任何东西没有被追踪或上演或未分期.我完全不知道为什么rebase失败了.
我在OS X 10.6.6和git 1.7.4上
.-(/Volumes/joshua/www/txfunds)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(joshua@Kusanagi)-
`--> git rebase bug586-test master-test
First, rewinding head to replay your work on top of it...
Applying: - comiitting code related to api permissions
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
inc/data.inc
templates/apipermissions_tpl.inc
templates/currencies_tpl.inc
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the …Run Code Online (Sandbox Code Playgroud) ➜~myprojectgit :(主人) git log
commit a99cce8240495de29254b5df8745e41815db5a75
Author: My Name <my@mail.com>
Date: Thu Aug 16 00:59:05 2012 +0200
.gitignore edits
commit 5bccda674c7ca51e849741290530a0d48efd69e8
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:36:39 2012 +0200
Create .gitignore file
commit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:13:05 2012 +0200
Initial commit (with a misleading message)
Run Code Online (Sandbox Code Playgroud)
reword我第一次提交的提交消息(6707a66)➜~myprojectgit :(主人) git rebase -i 6707
(...进入vim)
pick 5bccda6 Create .gitignore file
pick a99cce8 .gitignore edits
# Rebase 6707a66..a99cce8 onto …Run Code Online (Sandbox Code Playgroud) 作为Git用户,我经常遇到这种情况,我需要以一种不适合--amend或不适合rebase -ifixup提交的方式重做一个或多个提交.通常我会做类似的事情
git reset HEAD~1
# hack, fix, hack
git commit -a
# argh .. do I need to retype my message?
Run Code Online (Sandbox Code Playgroud)
我认为合理的撰写提交消息非常严重.它们通常包含较大的文本,其中包含对更改的引用和理由.到目前为止,我对通过未排序git reflog,git log复制和粘贴过程恢复旧提交消息的漫长过程感到非常恼火.
有没有更好的解决这个问题?如果我包含多个提交,它会怎么样?
编辑:经过一番思考之后,我认为我正在寻找的是一些git stash- like功能,用于提交消息,其中fixup/revision提交不合适.
git ×10
git-rebase ×10
git-merge ×2
rebase ×2
commit ×1
git-branch ×1
git-checkout ×1
git-commit ×1
git-reset ×1
merge ×1
message ×1
msysgit ×1
repository ×1
vim ×1