Home > Net >  git rebase -i HEAD~<n> does not show the commit list or the commands in vi
git rebase -i HEAD~<n> does not show the commit list or the commands in vi

Time:10-27

I am trying to squash come commits but the guides I find on the internet (e.g.this from Git) do not work for me:

> git checkout master
> git checkout -b masterBAK
> git log --oneline --graph --decorate -n 4
*   047687e (HEAD) Merged PR 100: Fix pytest using marker
|\  
| * 8ca0695 (origin/correct_bug) add something to pytest
| * 7b247c8 mock some function
|/  
*   5c5c75a (tag: v1.4.0) Merged PR 090: cleanup imports

> git rebase -i HEAD~3

I am now expecting to see a list of commits followed by a list of commands as in the link above. Instead I see a blank page in vi, i.e. a cursor where I can write using vim commands followed by tilde symbols. I can quit with ":q". What can I do to see the commits and squash them as described in the guide above?

I don't think it matters, but I use meld in some settings:

> git config -l
diff.tool=meld
merge.tool=meld
difftool.prompt=false
..
core.editor=/usr/bin/vi -w

p

CodePudding user response:

This is my config:

diff.tool=vimdiff
merge.tool=vimdiff
core.editor=vim # I think this is the important point
# I don't have difftool.promt

And If I do git rebase -i <commit> I can see what you are looking for, the option to squash commits.

CodePudding user response:

core.editor=/usr/bin/vi -w

This is the wrong setting. In particular the -w option here is evil.

If your vi is one of the more traditional versions, -w tells the editor that the next argument is the window size. This is expected to be a number, and if it's not a number, odd things may happen. Git will pass a file name here, which generally won't be a number. The effect will be to ignore the file name, and open a temporary file.

If your vi is a vim variant, the -w flag means that the next argument is a script output file. Again, this consumes the file name that Git wants vim to open, so that vim opens an empty temporary file instead. Worse, vim now appends stuff that you type into the rebase instruction sheet.

Whatever told you to put -w here is wrong. Remove the -w.

  •  Tags:  
  • git
  • Related