Question

I'm trying to squash a few commits into a pull-request-ready package for a github project I'm hoping to contribute to, but using git rebase -i master isn't giving me the options I expect (based on reading on StackOverflow and elsewhere. This is the first time I've attempted to squash commits, so I'm probably just missing something.

The history of the project is something along the lines of:

# On branch master
git pull origin master
git fetch upstream
git rebase upstream/master
git checkout -b feature
git commit -m "some work"
git commit -m "a little more work"
git commit -m "finishing up feature"
git checkout master
git pull origin master
git fetch upstream
git rebase upstream/master
git checkout feature

at this point there have been no changes in origin/master or upstream/master, so even without rebasing my feature branch is linear with both origin and upstream. When I do git rebase -i master, none of my commits are listed in the editor that pops up, which is completely blank, and the output of the rebase is Successfully rebased and updated refs/heads/feature.

I know I could use

git checkout master
git merge --squash feature

but my understanding is that I'll lose all the history if I do that.

Is there another way to accomplish what I want, or am I just missing the obvious?

UPDATE

What I expect to see is an editor with the commits I've made in my feature branch listed so that I can select which ones to pick and which to squash. What I actually see is an empty editor, which makes me wonder if because my current branch is linear to my master branch, nothing needs to be rebased and so no commits show up in the editor (although I suppose I would have expected to get a "nothing to rebase" sort of message instead of the success message noted above)

Was it helpful?

Solution

As noted in the comments, the issue wasn't with the git rebase -i master command at all, but instead with my editor, which wasn't handling the input from git to appropriately display the available commits.

Changing to a different editor resolved the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top