Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Desktop: "Update from <branch>" button

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

like image 813
Sensei Avatar asked Oct 14 '15 11:10

Sensei


People also ask

How do I update my GitHub repository on my desktop?

In GitHub Desktop, use the Current Branch drop-down, and select the local branch you want to update. To pull any commits from the remote branch, click Pull origin or Pull origin with rebase. Resolve any merge conflicts in your preferred way, using a text editor, the command line, or another tool.

What does the GitHub Update branch button do?

The Update branch button on the pull request page lets you update your pull request's branch with the latest changes from the base branch. This is useful for verifying your changes are compatible with the current version of the base branch before you merge.


4 Answers

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.

like image 168
SoFarther Avatar answered Oct 10 '22 01:10

SoFarther


When I hover over the button, it explicitly says "Merge XX commits from "

enter image description here

like image 42
Andrew Harry Avatar answered Oct 10 '22 02:10

Andrew Harry


Just go into "Branch" menu, then "Merge into current branch..." and choose the branch you want to get your "update" from.

like image 3
adheus Avatar answered Oct 10 '22 02:10

adheus


GitHub themselves say it's just git merge <defaultBranch>.

To quote the official comments on the issue in the GitHub Desktop repo:

This menu item emits the update-branch message to the main window (what we call the renderer in Electron terminology). The updateBranch method then looks for your default branch (typically master). Git operations in the app use the Git command line, so what we're doing in the app is just a git merge master into your current branch.)

like image 1
Mark S Avatar answered Oct 10 '22 01:10

Mark S