Skip to content

[Feature Request] Create Merge/Pull Request from branch context menu #980

Closed

Description

@p-fischer

It would be a great workflow improvement if merge/pull requests could be initiated by right-clicking on a branch, clicking on the context menu option "Create Merge Request on origin", which will re-direct to the brower.

While the integration with e.g. GitHub and GitLab would be ideal, I saw in #250 concern was expressed about these integrations.

As a fallback I suggest to add support for custom actions on branch level, so users can replicate the "Create Merge Request" context menu option themselves.

Activity

  1. self-assigned this
    on Feb 14, 2025
  2. added
    enhancement
    on Feb 14, 2025
  3. p-fischer commented on Feb 14, 2025

    @p-fischer
    Author

    I successfully tested this on Ubuntu 24.10.
    Awesome! Thank you very much!

  4. 40detectives commented on Sep 10, 2025

    @40detectives

    I successfully tested this on Ubuntu 24.10. Awesome! Thank you very much!

    @p-fischer Can you share an example of how to setup the custom action to create a pull request in github (for example)?

  5. p-fischer commented on Sep 17, 2025

    @p-fischer
    Author

    I setup a custom action so I can right-click on a branch name in the left column, select "Custom Action" and click on my custom action "Create Merge Request", which will open (in my case) GitLab in a website with the correct branches selected.
    Building this for GitHub should work in the equivalent way.

    Steps to create the custom action:

    1. Open repository in SourceGit
    2. Open repository settings (That's the settings icon left of the fetch icon. Don't confuse the repository settings with the global settings. A dialog with title "Repository Configure" will open.)
    3. Click on tab "CUSTOM ACTION"
    4. Click on + icon on the bottom left
    5. Pick name for the custom action (e.g. "Create Pull Request" or "Create Merge Request")
    6. Select scope "Branch" (At least if you want the website to be opened with preselected branches)
    7. Skip input controls
    8. (Outside of SourceGit) Create a script (see below about the script content)
    9. Make script executable (using chmod +x FILENAME on Linux)
    10. (Back to SourceGit dialog) Link script in "Executable File"
    11. For Arguments set ${BRANCH}
    12. Check wait for action exit

    regarding 8:

    Create a script file. Under Linux I chose the path ~/.config/SourceGit/scripts/push_and_create_merge_request_from_branch.sh

    My script looks like this:

    #!/bin/bash
    
    current_branch=$1 # the branch you clicked on
    target_branch=main # the branch you want to merge into
    remote=origin
    gitlab_repo=https://[Enter project URL here]
    
    # push the current_branch
    git push ${remote} ${current_branch}:${current_branch}
    
    # open GitLab website to create merge request
    xdg-open ${gitlab_repo}/merge_requests/new?merge_request[source_branch]=${current_branch}&merge_request[target_branch]=${target_branch}
    

    Some notes on the script

    • Pushing the current branch is optional. I personally added it for convenience.
    • xdg-open is a Linux specific command to open a URL using the default browser. If you're on Windows or MacOS you need to change it.
    • The script, especially the last line is specific to GitLab and how the URL for creating a merge request looks like. For GitHub start creating a new pull request in the web, copy the URL and replace the concrete branch names with the variables source_branch and current_branch. You could extract the repository URL into a variable like I did but you don't need to. This might be nice if you want to re-use the script.
    • Your target/default branch might have a different name than main. If so change it.

    ... OR as an alternative for GitHub for the script you could install GitHub CLI and use the PR create command

  6. DJ-Huang commented on Nov 25, 2026

    @DJ-Huang

    I opened draft #2901 as a follow-up to the branch context-menu workflow discussed here. Its AI → Create PR/MR… action lets you review the source and target remotes, edit the title and description or draft them with a configured CLI, and then publish directly to GitHub or GitLab with a token. The PR includes a focused diff and links to the companion CLI change.

    PR/MR dialog showing separate source and target remotes and an editable draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions