Tutorial part 2: Initialize a repository for your application
Initialize a local Git repository for an application in the ServiceNow IDE and push it to a remote Git repository in GitHub to manage the application in source control.
Before you begin
Complete Tutorial part 1: Create an application in the ServiceNow IDE.
Role required: admin
Procedure
-
From the Activity Bar, select the Source Control view (
).
-
Initialize a Git repository that's local to the ServiceNow IDE.
- Select Initialize Repository.
- Press Enter to use main as the default branch name.
A local repository is initialized for your application, and the application files that are tracked in source control are in the Untracked Changes list. Application files and directories specified in the .gitignore file aren’t tracked in source control.Tip:If you select a file in the list, you can view a comparison of the current and previous version of the file in the Diff editor.Before you can push your application to a remote Git repository, you must stage and commit your changes in the local Git repository.
-
Stage and commit your changes.
-
From the Untracked Changes list, select the Stage All Untracked Changes icon (
).
Your changes move to the Staged Changes list. - In the message box, enter a commit message.
-
Select the Commit icon (
).
Now that you have committed changes, you can expand the Commits section to see your commit history and details about each commit.
To push your changes to a remote repository that other developers can access, you need to create a repository with a Git provider like GitHub and generate a personal access token.Note:The following steps demonstrate using GitHub and basic authentication as an example, but you could use another Git provider of your choosing or OAuth 2.0 authentication. For more information, see Integrating source control with the ServiceNow IDE. -
From the Untracked Changes list, select the Stage All Untracked Changes icon (
-
Create a remote repository.
- Log in to your GitHub account.
-
Select the Create new menu (
) and select New repository.
-
On the New repository form, fill in the fields.
- Select Create repository.
-
From your repository, copy the HTTPS URL and paste it somewhere that you can easily access it again for use in the following steps.
-
Create a personal access token.
- From your user profile in GitHub, select Settings.
- From the settings categories, select Developer Settings.
- From the Personal access tokens menu, select Tokens (classic).
- From the Generate new token menu, select Generate new token (classic).
-
On the New personal access token (classic) form, select the repo scope and fill in the remaining required fields.
The repo scope is required to connect to the ServiceNow IDE.
- Select Generate token.
-
Copy the token and paste it somewhere that you can easily access it again for use in the following steps so you don't need to regenerate it.
-
Configure basic authentication in the ServiceNow IDE to connect to the remote repository.
- Navigate to the ServiceNow IDE.
-
Use one of the following keyboard shortcuts to open the command palette:
- Windows: Ctrl-Shift-P
- Mac: Cmd-Shift-P
- Enter Git: Set IDE Git credentials and press Enter.
- From the New Git credential form, select Basic auth.
-
On the form, fill in the fields.
Table 1. New Git credential form Field Description Git repository URL The HTTPS URL of the Git repository you created in GitHub. For example: https://github.com/<owner>/hello-world.git. Git username Your GitHub user name. Personal access token The personal access token that you generated from GitHub. - Select Submit.
Now that your authentication credentials are configured, you can push your application to the remote repository.Tip:If you need to manage existing Git credentials, use the Git: Manage Git credentials command from the command palette. -
Push your changes to the remote repository.
-
Select the More actions menu icon (
) and select Push.
- Enter the HTTPS URL of the remote Git repository and press Enter.
The application is added to the remote repository in GitHub, and changes to the application across users are tracked remotely. -
Select the More actions menu icon (
Result
You can check out or create branches in the repository and push changes to the remote repository. For more information, see Using source control in the ServiceNow IDE.
What to do next
Continue to Tutorial part 3: Define a table in ServiceNow Fluent code.