Streamline Your ServiceNow Development: Connecting Instances to Git for Seamless Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2025 12:06 PM
Hi Community,
This technical guide, focusing on a crucial process for ServiceNow developers: connecting ServiceNow instances to Git for seamless change management. This guide is particularly valuable given that Personal Developer Instances (PDIs) can expire, potentially leading to lost work during Proof of Concept (POC) development. By leveraging Git, you can effectively deploy changes from your repository directly into ServiceNow.
Two ServiceNow Personal Developer Instances (PDIs):
Source Instance: https://dev313686.service-now.com
Target Instance: https://dev313508.service-now.com
Linking Your ServiceNow Instance to GitHub
Step 1: Create a New Repository on GitHub
The first step is to set up your repository on GitHub. This will be the central hub for your ServiceNow application's code.
Login to GitHub Account and Navigate to GitHub Dashboard.
Click on Create new repository.
Give the Repository Name: "your_own_name".
Click Create to finalize the repository creation.
GitHub Application Repository Created:
Step 2: Create a Credential Record in ServiceNow
To enable your ServiceNow instance to communicate with your GitHub repository, you'll need to create a credential record.
In the main ServiceNow window (outside of Studio), use the All menu to open Connections & Credentials > Credentials.
2. Click the New button.
3. From the What type of Credentials would you like to create? list, select Basic Auth Credentials.
Now, configure the Basic Auth Credentials record with the following details:
4. Name: GitHub Credentials - <your GitHub Username>
5. User name: <your GitHub Username>
6. Password: token (This is where your Personal Access Token will go, which we'll generate next).
Generating Your GitHub Personal Access Token
A Personal Access Token (PAT) acts as a secure password for programmatic access to your GitHub account.
Go to your GitHub Profile.
Navigate to Developer settings.
Generate a New token (classic), ensuring you grant appropriate permissions (typically repo scope for full control over repositories).
Tip: Select "Tokens (Classic) > Generate New Token (Classic)" for this process.
Once generated, copy this new token immediately as you won't be able to see it again.
Step 3: Link Your Application to Source Control (ServiceNow Studio)
With your GitHub repository and ServiceNow credentials set up, it's time to connect your ServiceNow application to source control via ServiceNow Studio.
Open ServiceNow Studio.
Open the specific application you wish to link.
Go to Source Control > Link To Source Control.
Provide the repository URL from GitHub and select the Basic Auth Credentials you created earlier.
- Update the branch name instead of following default. and Click Link To Source Control.
Once the linking process is complete, you can start seeing changes of your instance (e.g., tables and ACLs) reflected in your repository.
Step 4: Manage Changes and Commit to Git
Once your application is linked, any modifications you make within it can be committed directly to your GitHub repository.
1. Make changes in your source instance: Implement your desired updates to flows, tables, or other application components.
2. Commit the updated changes: From ServiceNow Studio, commit these changes to your linked GitHub repository. This effectively versions your work.
3. Above are the files I committed to GitHub repository.
Step 5: Deploy Changes to a Target Instance
To push your committed changes to another ServiceNow instance (your target instance), follow these steps:
On the target instance, open ServiceNow Studio.
Click Import Application and Update Repository link and Credentials same as source
- Click Import.
Step 6: Verify Your Deployment
Source Instance: (Created a flow and added one Update action)
Target Instance: (Shows the same flow as the source)
Propagating Updates:
Now, let's say I've updated the flow in the source instance with the description "Successfully Change Moved."
Source Instance:
Here we can see only the latest changes that are available in application on source instance
The Updated Flow is committed using studio
1. Open the application On the target instance, Go to Source Control > Apply Remote Changes.
2. This action will fetch the latest changes from your GitHub repository. You'll typically see a prompt to Confirm Merge and done.
3.GitHub: click the create Pull request of your branch
4. If you're managing multiple branches or encounter conflicts, you may need to select merge pull request to integrate the changes correctly.
5. Go to Source Control > Apply Remote Changes on Target Instance
Result:
The final step is to confirm that your changes have been successfully deployed to the target instance.
Verify updates on the target instance: Check that the changes you made (e.g., updated flows, new tables) are now present and fully functional on your target ServiceNow instance as you see description updates as "Successfully change Moved"
References:
This guide draws upon information and best practices outlined in the official ServiceNow product documentation
ServiceNow Product Documentation: Managing the Development Environment - Source Control
Conclusion:
This guide provides a robust method for managing your ServiceNow development. It ensures your work is backed up, version-controlled, and easily deployable across instances, even if your PDI expires. This process significantly streamlines the deployment of your innovations.
- 291 Views