You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Create Merge/Pull Request from branch context menu #980
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.
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:
Open repository in SourceGit
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.)
Click on tab "CUSTOM ACTION"
Click on + icon on the bottom left
Pick name for the custom action (e.g. "Create Pull Request" or "Create Merge Request")
Select scope "Branch" (At least if you want the website to be opened with preselected branches)
Skip input controls
(Outside of SourceGit) Create a script (see below about the script content)
Make script executable (using chmod +x FILENAME on Linux)
(Back to SourceGit dialog) Link script in "Executable File"
For Arguments set ${BRANCH}
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
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.
Activity
feature: support add custom actions for selected branch (#980)
p-fischer commentedon Feb 14, 2025
I successfully tested this on Ubuntu 24.10.
Awesome! Thank you very much!
40detectives commentedon Sep 10, 2025
@p-fischer Can you share an example of how to setup the custom action to create a pull request in github (for example)?
p-fischer commentedon Sep 17, 2025
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:
chmod +x FILENAMEon Linux)${BRANCH}regarding 8:
Create a script file. Under Linux I chose the path
~/.config/SourceGit/scripts/push_and_create_merge_request_from_branch.shMy script looks like this:
Some notes on the script
xdg-openis a Linux specific command to open a URL using the default browser. If you're on Windows or MacOS you need to change it.source_branchandcurrent_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.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
DJ-Huang commentedon Nov 25, 2026
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.