Github Desktop: "Update from <branch>" button

Sensei picture Sensei · Oct 14, 2015 · Viewed 12.7k times · Source

In this picture below from the Github(c) Desktop App there ist this button "Update from master" (in this case). I was wondering if anyone had the insight what exact git function it triggers. Primarily I'm interested if merge or rebase is used. (I could not find any sort of log console).

enter image description here

Answer

SoFarther picture SoFarther · Dec 4, 2015

The git commands underlying the buttons in GitHub Desktop are not well-documented, so I investigated a while back. I concluded that the "Update from..." button dispatched

git merge --no-ff -m "Merge <auto_text> <branch_name>" <branch_name>

or something nearly identical with the "Compare" branch set to <branch_name> in the GitHub Desktop GUI.

I reached the conclusion in the following way:

First, I forked a repository that I control to my GitHub account. Then, I cloned the repository from my GitHub account to my local machine. Next, I committed a small change to the (original) main remote repository. Finally, I used git fetch <remote_name_assigned_to_main_repo> (<remote_name>, hereafter) to bring the single commit to my local machine. After this fetch, the "Update from..." button lit up.

This set up a scenario in which the branch checked out, master in my local repository, was one commit behind master in the main remote repository. By default, git merge <remote_name> would have produced a fast-forward merge (without a merge commit).

Using the "Update from..." button, however, resulted in the following reflog entry:

HEAD@{0}: merge <remote_name>/master: Merge made by the 'recursive' strategy.

And a merge commit in the log:

Merge remote-tracking branch '<remote_name>/master'

(The 'recursive' strategy "...is the default merge strategy when pulling or merging one branch." per the manual.)

I also set up a scenario in which git rebase might have been an option, but saw the same merge behavior.