git rebase -i HEAD〜7 - 只显示“noop”在编辑器中 [英] git rebase -i HEAD~7 -- showing only "noop" in editor

查看:856
本文介绍了git rebase -i HEAD〜7 - 只显示“noop”在编辑器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图将一个在HEAD中的提交压缩成几个后面的提交。然而,当我运行 git rebase -i HEAD〜7 时,我在编辑器中只显示了一个 noop



我在一个分支( cleanup )中工作,我在我第一次创建(在 reflog 中找到的SHA1上使用 checkout -b cleanup ... rebase 经验和我意外删除了所有这些提交;问题是,我不确定分支的父母是什么(如果这很重要的话,在这里)。

我只是试着去做我读过很多次的东西:我想稍微修改一些不是最近提交的提交的代码。无论这是一个应用程序挤压还是只是在我到达那一点时对其进行修改,我都不知道。



我也在STDOUT上看到这是编辑器在运行上面显示的rebase命令后开始:

  $ git rebase -i HEAD〜7 
usage:git rev- list [OPTION]< commit-id> ... [ - paths ...]
限制输出:
--max-count =< n>
...

除了 HEAD〜7 参考,我已经尝试指定整个SHA1,并且不同的refspecs给本地和远程分支。同样的结果......



我错过了什么?感谢您的帮助!






编辑:



  $ git log --oneline HEAD〜7..HEAD 
d0fd20e temp修复resume_cities表
ea2ffdf修复db / seeds.rb以反映最近的数据库结构修改
dbd2b8b添加几个与Geonames表一起使用的模型/脚手架
9759091修复ResumeSkill模型文件的名称。
3fc3134将以前提交的SHA1添加到迁移的评论中,以帮助连接到该迁移。
bacbeb2整合数据库迁移!读我!
0c49a57移回LinkedIn,omniauth和twitter的宝石版本

这是 bacbeb2 commit我想修改 d0fd20e






根据@MarkLongair的建议,我在 / usr / lib / git-core /

  $ git rebase -i HEAD  〜7 

... ...为简洁起见,输出静音,查看完整的输出,在这里:http://gist.github.com/1163118]
+ read -r shortsha1 rest
+ sed -ns / ^> // p
+ git rev-list --no-merges --cherry-pick --pretty = oneline --abbrev-commit --abbrev = 7 --reverse --left-right --topo-order 2c51946812a198ca908ebcad2308e4b8274624b3 ... d0e9ff6d9c1f8bc374856ca2a84ad52d6013b5bf
usage:git rev-list [OPTION]< commit-id> ... [ - paths ...]
restrict输出:
--max-count =< n>
--max-age =< epoch>
--min-age =< epoch>
--sparse
- 不合并
- 移除空白
- 全部
- 分支
- 标签
--remotes
--stdin
--quiet
订单输出:
--topo订单
- 日期订单
--reverse
格式输出:
- 父母
- 儿童
- 对象| --objects-edge
--unpacked
--header | --pretty
--abbrev =< n> | --no-abbrev
--abbrev-commit
- 左对右
特殊用途:
--bisect
--bisect-vars
--bisect-all
+ test t =
+ test -s /home/ryan/Projects/social-jobs/.git/rebase-merge/git-rebase-todo
+ echo noop
[...]

我说'奇怪的输出'是因为如果我运行

  $ git rev-list --no-merges --cherry-pick --pretty = oneline --abbrev-commit --abbrev = 7 --reverse --left-right --topo-order 2c51946812a198ca908ebcad2308e4b8274624b3 ... d0e9ff6d9c1f8bc374856ca2a84ad52d6013b5bf 
> 0c49a57移回LinkedIn,omniauth和twitter的宝石版本
> bacbeb2整合数据库迁移!读我!
> 3fc3134将之前提交的SHA1添加到迁移的评论中,以帮助连接到该迁移。
> 9759091修复ResumeSkill模型文件的名称。
> dbd2b8b添加几个与Geonames表一起使用的模型/脚手架
> ea2ffdf修复db / seeds.rb以反映最近的数据库结构修改
> d0e9ff6!temp修复resume_cities表!temp


解决方案

/ strong>我的.bashrc 设置IFS:

 #从IFS $ b $中删除空格字符b#(http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#IFS)
IFS =`printf'\\\
\t'`

我根本不记得为什么我把它放在那里。我确定它与'修复UNIX / Linux文件名'有关,就像我包含该URL一样。不知道。

尽管如此,我删除了该语句和:POOF! 没有更多问题!



非常感谢@MarkLongair的帮助!


I am trying to squash a commit which is at HEAD into one that is a few back. When I run git rebase -i HEAD~7, however, I am presented with just a noop in the editor! I am totally confused about how this is supposed to work.

I am working in a branch (cleanup) that I created (using checkout -b cleanup ... on the SHA1 I found in reflog) after I had my first rebase experience and I accidentally deleted all of those commits; point is, I am not sure what the branch's parent is (if that matters, here).

I am simply trying to do what I have read about many times: I want to modify slightly some commited code that isn't the most recent commit. Whether that's an application for "squashing" or just amending it when I get to that point, I don't know.

I am also seeing this on STDOUT as the editor starts after running the rebase command shown above:

$ git rebase -i HEAD~7
usage: git rev-list [OPTION] <commit-id>... [ -- paths... ]
  limiting output:
    --max-count=<n>
    ...

In addition to the HEAD~7 reference, I have tried specifying the entire SHA1, and different refspecs to local and remote branches. Same result for everything...

What am I missing? Thanks for your help!


Edit:

$ git log --oneline HEAD~7..HEAD
d0fd20e temp Fix resume_cities table
ea2ffdf Fix db/seeds.rb to reflect recent database structure modifications
dbd2b8b Add several models/scaffolds that go along with the Geonames tables
9759091 Fix name of the ResumeSkill model file.
3fc3134 Added the SHA1 for the previous commit to the comments on the migration, to help link back to that.
bacbeb2 Consolidate database migrations! READ ME!
0c49a57 Moved back to gem versions of linkedin, omniauth, and twitter

It's the bacbeb2 commit I want to amend with the d0fd20e


Per the recommendation of @MarkLongair, I added set -x to /usr/lib/git-core/git-rebase--interactive and saw the following strange output:

$ git rebase -i HEAD~7

[... output muted for brevity, see the full output, here: http://gist.github.com/1163118]
+ read -r shortsha1 rest
+ sed -n s/^>//p
+ git rev-list --no-merges --cherry-pick --pretty=oneline --abbrev-commit --abbrev=7 --reverse --left-right --topo-order 2c51946812a198ca908ebcad2308e4b8274624b3...d0e9ff6d9c1f8bc374856ca2a84ad52d6013b5bf
usage: git rev-list [OPTION] <commit-id>... [ -- paths... ]
  limiting output:
    --max-count=<n>
    --max-age=<epoch>
    --min-age=<epoch>
    --sparse
    --no-merges
    --remove-empty
    --all
    --branches
    --tags
    --remotes
    --stdin
    --quiet
  ordering output:
    --topo-order
    --date-order
    --reverse
  formatting output:
    --parents
    --children
    --objects | --objects-edge
    --unpacked
    --header | --pretty
    --abbrev=<n> | --no-abbrev
    --abbrev-commit
    --left-right
  special purpose:
    --bisect
    --bisect-vars
    --bisect-all
+ test t = 
+ test -s /home/ryan/Projects/social-jobs/.git/rebase-merge/git-rebase-todo
+ echo noop
[...]

I say, 'strange output' because if I run the rev-list command directly from my shell, it works as expected:

$ git rev-list --no-merges --cherry-pick --pretty=oneline --abbrev-commit --abbrev=7 --reverse --left-right --topo-order 2c51946812a198ca908ebcad2308e4b8274624b3...d0e9ff6d9c1f8bc374856ca2a84ad52d6013b5bf
>0c49a57 Moved back to gem versions of linkedin, omniauth, and twitter
>bacbeb2 Consolidate database migrations! READ ME!
>3fc3134 Added the SHA1 for the previous commit to the comments on the migration, to help link back to that.
>9759091 Fix name of the ResumeSkill model file.
>dbd2b8b Add several models/scaffolds that go along with the Geonames tables
>ea2ffdf Fix db/seeds.rb to reflect recent database structure modifications
>d0e9ff6 !temp Fix resume_cities table !temp

解决方案

This issue was caused by my .bashrc setting IFS:

# remove the space character from IFS
# (http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html#IFS)
IFS="`printf '\n\t'`"

I cannot remember at all why I put that in there. I'm sure it had something to do with 'fixing UNIX/Linux filenames' as indicated by my inclusion of that URL. Dunno.

Regardless, though, I removed that statement and: POOF! No more problem!

Thanks so much to @MarkLongair for his help!

这篇关于git rebase -i HEAD〜7 - 只显示“noop”在编辑器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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