views:

41

answers:

1

I have a public repository on github that I'm having trouble handling pull requests with inside GitExtensions. I've done 3 so far, and I don't think any of them have worked properly or worked where I want them to.

  1. On the 19th, I tried to handle a pull request that Yi Jiang created. In GitExtensions, I did a pull within GitExtensions, putting in the remote repository, selecting master as the remote branch, and leaving Merge remote branch to current branch as the default. I clicked Pull and it completed without error. There were a couple of things that I cleaned up, and then I then did a push in GitExtensions. It didn't fill in a commit message, which surprised me, so I just tossed in the URL of Yi Jiang's commit because I didn't know what else to do. The result was that it shows up as a pair of commits, one from Yi Jiang as an author and one from me as an author.

  2. Later on the 19th, I tried to handle a pull request that Michael created. Since it seemed pretty clear that I did the first one wrong, I looked for another option. I ran the first set of commands found here, and this does seem to have worked great. The only problem is that I had to do it via the command line rather than within GitExtensions.

  3. Another pull request from Yi Jiang. Since doing it via GitBash rather than GitExtensions seemed to work the last time, I tried it again. This time however, it wouldn't complete because there were merge conflicts. Ok, so I go to GitExtensions and do a merge because I know that will let me solve the conflicts. So, I open up the Merge branches dialog and select Merge with and select Yi Jiang's master branch leaving Keep a single branch line if possible (fast forward). I resolve the conflicts and do a push. It automatically put in the commit message for me. This shows up as 4 entries, 3 from Yi Jiang as the author, and 1 from me as the author. Doesn't seem right.

So my question is, how am I supposed to do this properly? I've got another pull request and I want to make sure I am handling it correctly. The fork queue says it won't apply cleanly, so I foresee that I'll need to do a merge. I want to make sure that I am merging properly and that the branches and the commits are being attributed to the people that did the work. If there are edits that need to be done, should I just do the merge/push first and then do a 2nd commit just with the single branch? How does this affect needing to resolve merges?

Could someone walk through the exact process of correctly handling a pull request in GitExtensions?

+2  A: 

#1 sounds normal - The first is the commit from the branch you pulled in, the second is the merge commit (that actually merges the branches together). The merge commit is by whoever does the git pull - but if you look at the files in git blame, you'll see that the blame lines are all for the original author (merge commits don't actually add blame lines unless you resolve conflicts).

#3 also seems normal for the same reason - merging adds a single commit that actually merges the branches.

My guess with #2 is that the pull request there actually was a fast-forward, and thus no merge commit was necessary, whereas #1 and #3 were not fast-forward (even if they did merge without conflicts, they weren't direct descendants of the your HEAD).

Basically, I think you're actually doing it right, even if it seems a bit odd. :)

If you want a slightly more length explanation of the differences between fast-forward and merge, here's someone else's words:

On merges and "fast forward"

You'll notice that we've been seeing the phrase "fast forward" several times. This is a special-case operation performed by "git merge" where a branch can be advanced along a linear sequence. This happens whenever you pull changes that build directly on top of the same commit you have as your most recent commit. In other words, there was never any divergence or simultaneous commits created in parallel in multiple repositories. If there had been parallel commits, then "git merge" would actually introduce a new merge commit to tie the two commits together.

When a non-fast-forward merge occurs, there is always the possibility that a conflict occurs. In this case, "git merge" will leave conflict markers in the files and instruct you to resolve the conflicts. When you are finished, you would issue a "git commit -a" to create the merge commit.

(From http://cworth.org/hgbook-git/tour/)

Edit

I went and looked at the actual repository on Github. The last two pulls (#2 and #3) seem to have worked properly, and done what should have been done - fast-forwarding in the case of #2, and merging (with an added merge commit) in #3.

I'm not quite sure what happened with #1 - somehow, it appears, part of the changes got put into a separate commit by you? Couldn't really tell better without having been able to look at what actually was done at the time. Perhaps you had uncommitted changes and you committed them without noticing?

Amber
(That said, you might consider learning how to resolve conflicts via the command line - I've always found that Git is most natural from the command-line interface; all of the GUIs seem to make one thing or another harder than they need to be.)
Amber
See my edit. I did do an edit on the first one as I was able to clean up some of the code. My question now asks if I should have done that as a totally separate commit.
rchern
There are two options. #1 is to do it as a separate commit - this is probably the best option, to be honest - it doesn't mess with history (so you can still trace the line of development back to the other person's repository), and it makes it clear what things you changed as part of the cleanup. #2 is to use `git commit --amend`, which is kind of like normal committing except that it rolls your changes into the latest commit (and thus attributing them to whoever authored that commit), and doesn't create a new commit. Occasionally this is useful, but it doesn't mention that you made changes.
Amber
(cont.) Instead, it looks like the changes "were always there" - but since it's changing the contents of a commit, the SHA for that commit will change, and thus it won't match the SHA in the repository you pulled from. Thus, the best option is #1 - pull in the remote branch and merge it, then add another commit after the merge of your own to clean up the code.
Amber