How to merge a branch to main if that branch is behind and ahead of main

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 03:03 PM
Hi, I'm learning Studio + version control 🙂
I've messed up my repository. It's on PDI, but still.
I've commited a branch, let's say "newBranch" that is behind "main" by two commits (there were changes added to "main" after the creation of "newBranch"), and ahead of "main" by 3 commits (thanks to fresh changes in "newBranch").
I would like to straighten that, so that "newBranch" was not behind "main" anymore. After that I wanted to merge changes from "newBranch" to "main".
in short:
1. Creation of "newBranch" based on "main"
2. Changes commited to "main"
3. Changes commited to "newBranch"
Now I want to
4. merge "main" -> "newBranch"
5. merge "newBranch" -> "main"
The problem is that on github when I try to make a pull request to make that merge, I click on "pull requests" -> "New pull request" and I choose that branches I want to merge I just can see info: "Able to merge. These branches can be automatically merged." But there's no space to provide a pull request title and no button "create pull request", probably because the branches are not aligned properly.
I've seen ideas of how to fix it using git commands in terminal, but in SNOW we don't have that possibility, have we?
Or maybe you have any other idea what could I do to merge my changes that I've done in "newBranch" to "main"?
Thanks in advance and have a great day!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 08:09 PM
Hello @Beata I_owiecka
Since ServiceNow Studio doesn't support direct merging of branches within the platform, you'll need to use GitHub for this process. You can follow below steps:
1) Update newBranch with changes from main:
- Go to your GitHub repository.
- Switch to newBranch.
- Create a pull request to merge main into newBranch.
- Complete the pull request. This will bring newBranch up to date with main.
2) Merge newBranch into main:
- After updating newBranch, create another pull request to merge newBranch into main.
- Complete the pull request.
If you’re not seeing the option to create a pull request, it might be due to the branches being out of sync.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 01:21 AM
Hello @Beata I_owiecka
In that case, you can try the following:
Rebase newBranch onto main:
- Unfortunately, ServiceNow Studio doesn’t support Git commands directly. You’ll need to use GitHub for this.
- On GitHub, go to your repository and switch to newBranch.
- Rebase newBranch onto main using the GitHub interface or a local Git client.
Force push (if necessary):
- If you’ve rebased locally, you might need to force push newBranch to GitHub.
- Be cautious with force pushing as it can overwrite history.
By following these steps, you should be able to align your branches and proceed with the merge.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 01:06 AM
Hello @Viraj Hudlikar
Yes, branches are out of sync. I've even mentioned how they got out of sync.
Do you know what can I do to make that merge possible?