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).
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.
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.
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.
When I hover over the button, it explicitly says "Merge XX commits from "
Just go into "Branch" menu, then "Merge into current branch..." and choose the branch you want to get your "update" from.
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). TheupdateBranch
method then looks for your default branch (typicallymaster
). Git operations in the app use the Git command line, so what we're doing in the app is just agit merge master
into your current branch.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With