Submitting multiple pull requests in a row causes commits to be added to the same PR

1.  Introduction

So, I was working on a feature branch of a forked repository and was about to push that branch in order to create a pull request out of it.

I develop my changes, test, commit, push the branch and create a PR.

2. Situation

However, while working on the fore-mentioned feature branch, I also noticed that another PR was needed. I’m working with IntelliJ, so, I at some point noticed that the git ignore file of the project didn’t include any mention to specific IDE-generated files

https://gyazo.com/e3fabc1617693fd2ce18d8b8eda7bbe4

3. Problem

Ok, cool, so, I have to create a new PR, cuz it’s about something totally different.

So, checked out a new branch, committed the changes, pushed the branch and…

https://gyazo.com/f95765dca77645b044ca2faf350ad1e9

What? Why my newly pushed branch is 2 commits ahead of master? I just pushed one commit!

Side note here is that if I create a new PR based on this branch, the changes of my first PR would still be included. So, I have to somehow remove them, synchronize my gitignore-branch with master and then push the branch again, by erasing the previously logged history.

4. Solution

Oke, lemme check:

https://gyazo.com/70a546b0930a6daae6f519e65cbffc0f

Pooooh, of course, when I checked out to a new branch, I have already pushed my first branch, so the newly created branch has on top of its HEAD the latest “local” changes. Let’s reset it back to a valid remote state. That is, just after cloning it:

https://gyazo.com/822ed7d3622bd5215f0435985c24da2d

I’m on the branch which has to do with the update of the .gitignore file, so I only wanna add the .gitignore file ot it and then force the push, so that I erase all the previously existing history of the tree and have a single commit displayed to my branch ( and my PR, of course):
https://gyazo.com/ad89906adea69dfa47e02559f3425535

5. Confirmation

Cool!
https://gyazo.com/482c1e450dddaf55e4fd1f874a680a4e

Cheers!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s