sourcegit-scm / sourcegit

Windows/macOS/Linux GUI client for GIT users
MIT License
610 stars 66 forks source link

[FEATURE] Update branch from main/master #216

Closed ScottRFrost closed 6 days ago

ScottRFrost commented 1 week ago

Recently upgraded to SourceGit after years of using GitHub Desktop. The only thing I really miss is that in GitHub Desktop if your currently checked out branch is other than the primary for the repo, there is a menu option under branch for "Update from main/master" that was a quick way to make sure your branch was up to date from main/master.

Please consider adding something similar to SourceGit! Thanks in advance!

love-linger commented 1 week ago

I've checked the implementation for Update from [default branch] feature of Github Desktop. From the perspective of its code, it only performs a merge operation:

private updateBranchWithContributionTargetBranch() {
  const { selectedState } = this.state
  if (
    selectedState == null ||
    selectedState.type !== SelectionType.Repository
  ) {
    return
  }

  const { state, repository } = selectedState

  const contributionTargetDefaultBranch = findContributionTargetDefaultBranch(
    repository,
    state.branchesState
  )
  if (!contributionTargetDefaultBranch) {
    return
  }

  this.props.dispatcher.initializeMergeOperation(
    repository,
    false,
    contributionTargetDefaultBranch
  )

  const { mergeStatus } = state.compareState
  this.props.dispatcher.mergeBranch(
    repository,
    contributionTargetDefaultBranch,
    mergeStatus
  )
}

You can simply run this option in SourceGit by select the default branch and use mouse right click to open context menu, then you will find a menu item to merge the default branch into current. For example:

image

ScottRFrost commented 4 days ago

Yeah, that's all it does. It's just a shortcut to do it easily.