0

I have a pull request where my original commit wasn't passing tests. I didn't look at it for a while and came back to it after a number of months. During this time the upstream repo had done a bunch of commits, so I merged them into my repo. I then added a commit that fixed the broken tests.

I'd like to squash my pull request into a single commit. I have:

2102f91 <-- original commit from Jan 2015
c202023 <-- merge from upstream Feb 2016
df22e9c <-- commit to fix tests Feb 2016

Is it possible to squash this or is it easier to delete the branch and redo my pull request?

Noodles
  • 858
  • 3
  • 13
  • 29
  • Looking at the commit history, it seems like your commits are not on their own branch, as `c202023` is between them. But then you mention the possibility of "deleting the branch". So are your commits on master, or on their own branch? – David Deutsch Feb 11 '16 at 19:37
  • Sorry, yes this is on its own branch – Noodles Feb 11 '16 at 20:06

1 Answers1

0

Since you have already pushed your existing branch (let's call it old_branch), I wouldn't rewrite it. Instead, I would create a new branch off of the latest master (let's call it new_branch). Then we can do a "squash merge":

git checkout master -b new_branch
git merge old_branch --squash

Now new_branch will contain a single commit with all of the stuff done in old_branch.

David Deutsch
  • 13,210
  • 3
  • 41
  • 45