2

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)

9
  • git rebase -i master should do what you expect if you have feature checked out. Try git rebase -i master feature if you're not on feature already. Commented Dec 10, 2012 at 15:24
  • i am most definitely on feature, and trying your suggestion results in the same behavior, but thanks! Commented Dec 10, 2012 at 15:38
  • so what options do you expect, and what do you actually see? Commented Dec 10, 2012 at 16:13
  • @Useless, question updated Commented Dec 10, 2012 at 16:24
  • OK, so how does gitk --all (or git log --graph, or the gui of your choice ...) show the relationship between origin/master, upstream/master, master and feature? Commented Dec 10, 2012 at 16:30

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.