Working with Github in SAP Business Application Studio (next generation of SAP Web IDE)
SAP Business Application Studio has recently been released to customers on Azure, AWS, Ali-loud.
Hands-on tutorials /How to guides : https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-business-application-studio
You can build business applications, OData Services/ REST API’s, Fiori Elements, SAP UI5 Freestyle applications, SAP S/4HANA extensions, Mobile services, Node JS app ,Java app ,ABAP development for SAP multi-cloud environment (CF), Azure
You can refer my previous blogpost for overview of next generation of WebIDE from “SAP Business Application Studio “, I will try to make sure that this blogpost act as central blog which will have all required material ,links to useful information, migration guides & help guides as references written from various experts which help developers
instead of referring many blog posts about “SAP Business Application Studio”
For how to develop applications using “SAP Business Application Studio “ tutorials please refer https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-business-application-studio
In this blog post I will cover Git scenarios
If you have requirement/questions “Working with Github in SAP Business Application Studio” or “Using SAP Business Application Studio with Github “ ,"How to setup Git" ,"How do i push or clone from Git" then this blogpost may help you . I will share my knowledge on this topic as Initially I also struggled to get it done as “SAP Business Application Studio” is new to most of us . Question1 ) Do I need to install git or any thing to interact with Github from in SAP Business Application Studio ? Answer) No need to install git or Github desktop or any tools Because “SAP Business Application studio comes with predefined set of development environments, auto tools, plugins to support Github” Question2) What are Pre-requisites or Knowledge? Answer) 1. Any Git account on code hosting platform for version control and collaboration i.e your organisation/corporate Github , github or GitLab, bitbucket Example: In this blog post I tried https://github.com/ 2.Just a browser to access SAP Business Application studio You can get trail account as described in this blog post SAP Business Application Studio Note: If you are familiar with git commands then your job will be easy Because “SAP Business Application Studio” allows you to run Git commands from terminal how we generally execute in GitBash or Visual Studio code terminal . Reference: https://git-scm.com/docs
What you’ll learn
1) Setup your username, email in SAP Business Application Studio 2) Password for your Github account 3) How to cache Username & Password (Token) in SAP Business Application Studio 4) Create a new repository on GitHub 5) Clone existing repository in SAP Business Application Studio from GitHub Url 6) How to Clone a Specific Branch from Git 7) Create Application in SAP Business Application Studio and Push to GitHub 8) Push code to GitHub 9) Push a branch to GitHub 10) Create a Pull Request (PR) 11) Merge a PR 12) Download ,import ,export Project code, files from SAP Business Application Studio
1) Setup your username, email in SAP Business Application Studio
- Open Terminal in SAP Business Application Studio, From Terminal Menu in Menu Bar
- Run below command from terminal either from Projects directory or Change the current working directory to your local project.
Terminal –> New terminal –> cd projects –> cd yourprojectrootfolder
git config –global user.email “firstname.lastname@example.org”
git config –global user.name “Showkath”
1.1) How do I know my email id in Github?
Go to Settings –> emails Section –> Make a note of public profile email
Please make sure that you enter valid email id from either Github or your corporate email id registered in Github
for example, email@example.com otherwise your code push fails
Instead of entering your private email address you can enter public profile email address
Note : If you enter your private email address & but u enabled “Keep my email address private”
Then you may face error “GH007 Your push would publish a private email address” to fix this error
you can enter public profile email address from your Github account
1.2) How to know the git username ,email ,github url saved during configuration in SAP Business Application Studio?
In terminal of SAP Business Application Studio run below git commands
The command “git config –list” will list the settings, repository details
There you should also find user.name and user.email.
To know the username, type: git config user.name
To know the email, type: git config user.email
2) Password for your Github account
As of now SAP Business Application studio support Personal access tokens instead of passwords
Personal access tokens (PATs) are an alternative to using passwords for authentication to GitHub when using the GitHub API or the command line i.e Personal access tokens function like ordinary OAuth access tokens. They can be used instead of a password for Git over HTTPS
Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS
You should create a personal access token to use in place of a password with the Github UI or with the command line
To create a token, follow the instructions described in the GitHub documentation
How to create personal access token
1)In the upper-right corner of Github page, click your profile photo, then click Settings.
2)Click Developer settings
3)Click Personal access tokens
4)Click Generate new token
5)Give your token a descriptive name (What’s this token for?)
6)Select the scopes, or permissions, you’d like to grant this token. To use your token to access repositories from the command line, select repo.
7)Using a token on the command line
For example, on the command line you would enter the following:
$ git clone https://github.com/username/repo.git
Go to Github or your corporate GitHub account
Make Sure to copy your new personal access token /oAuth token to notepad or any secure place ,latter you will use in SAP Business Application Studio Terminal ,Otherwise you can also regenerate new one if you forgot from github account .
Note : For corporate GitHub you can get oAuth token from example : https://github.xxxxx.corp/settings/tokens
3) How to Cache Username & Password (Token) in SAP Business Application Studio
You no need to enter login credentials, every time you commit or push your code to github repository
As SAP Business Application studio supports git commands you can user credential helper to store your credentials which is similar how your credentials stored in Windows machine à credential manager in the same way application studio cache your credential instead of retype username & password .
I think you have two options
1) .netrc in SAP Business Application Studio
2) …or Git Credential helper
Option1:.netrc in SAP Business Application Studio
To save your token in your dev space, create a .netrc file in the $HOME directory (/home/user) with the following content:
SAP Business Application Studio
Developer Guide PUBLIC 41
Option2 :Git Credential helper
Enter below commands once you login successfully when you push first time from Terminal
git config credential.helper cache –timeout=3600000
git config credential.helper store
Hear : 3600000 milliseconds equals to 60 minutes
To erase credentials use below command i.e to disable this cached username/password for your current local git folder, simply enter
git config credential.helper “”
4) Create a new repository on GitHub
A repository is usually used to organize a single project. Repositories can contain folders and files, images, videos, spreadsheets, and data sets – anything your project needs.
To create a new repository
- Go to https://github.com/ or your corporate Github account
- In the upper right corner, next to your avatar or identicon, click and then select New repository.
- Name your repository or project name for example : helloSAP
- Write a short description
Note : If you select Private type “You can choose who can see and commit to this repository.”
You can learn more about Github. hear https://guides.github.com/
Below are git commands you can execute in “SAP Business Application Studio” à Terminal
Instruction generated in Github
5) Clone existing repository in SAP Business Application Studio from GitHub Url.
- Copy Your application URL
You have 3 options to clone existing repository
1)via Welcome page
2) …or. via Command Palette
3) …or. Execute Git commands from Terminal
- In Welcome page “Click clone from Git” & enter Git your project Url
- Example : https://github.com/Showkath/helloSAP.git
… or alternately you can also use Command Palette
Go to “View Menu-> Select Find Commandà enter “git clone”
..or Alternately you can use “git clone your-git project url” from SAP Business Application Studio terminal
- Once Project cloned you can Open Workspace & select Project
Just for simplicity i have added one file & then pushed file to git hub repository cloned above https://github.com/Showkath/helloSAP.git
You can also create branch in github or via git commands & push you code to that branch
git add .
git commit -m “type your message about commit hear”
git push -u origin dev
Hear dev is one of branch created in github in repository.
Then enter Username & Personal access token again if you have not cached or password expired as explained in above sections.
6) How to Clone a Specific Branch from Git
When u run below command ,if this repository contains many branches , this fetch all branches in github repository and you can easily switch between each to see each branch with below commands
git clone <repository url?
git clone https://github.com/SAP/openui5-sample-app.git
git branch <branchname>
Example : git branch -karma-test
How to Clone a Specific Branch
Now let’s clone a specific branch from Github repository. There are two ways to clone a specific branch. There are two options
git clone –branch <branchname> <remote-repo-url>
Example : git clone –branch release-0.23 https://github.com/SAP/ui5-webcomponents.git
This automatically configures release-0.23 as the local branch but still tracks other branches.
git clone –branch <branchname> –single-branch <remote-repo-url>
Example : git clone –branch release-0.23 –single-branch https://github.com/SAP/ui5-webcomponents.git
This performs the same action as option1 , It allows you to only fetch files from the specified branch without fetching other branches.
Note : Instead of –branch you can also use short form -b is an alias for –branch
git clone -b <branchname> <remote-repo-url>
7) Create Application in SAP Business Application Studio and Push to GitHub
Let’s assume you already created applications using Project templates in SAP Business Application Studio with the help of below tutorials
Question ) What Kind of applications I can build using SAP Business Application Studio?
Or you may have followed develop Your First SAPUI5 Web App with SAP Business
Lets say i have given Project name as “helloSAPUI5CF”
I am not covering all steps hear to how to create project , please follow awesome tutorials /how to guides available from SAP Developers Community
# Develop Your First SAPUI5 Web App with SAP Business Application Studio
# Create a Web Front End with SAPUI5
# Deploy Your First SAPUI5 App to Cloud Foundry
# Create an SAP Fiori App Using SAP Business Application Studio
# How to develop Fiori App in SAP Business Application Studio
# All Tutorials/Exercises :
Once project is ready now you would like to push project to Github ,please follow below steps
Please read above sections if you have missed before proceeding further
- Setup your username, email in SAP Business Application Studio.
- Know your Password for your git hub
Then You have two options “Create a new repository on GitHub” or do everything from git commands git init
I follow this easy approach I.e I will create empty repository with same name I have given for project
for example : helloSAPUI5CF
- Please follow “Create a new repository on GitHub” in above section in github or your corporate github.mycompany.com
- Execute below commands from your project root directory in SAP Business Application Studio Terminal
- cd projects
- cd helloSAPUI5CF
- git init
- git add .
- git commit -m “my SAPUI5 CF first commit”
- git branch -M main
- git remote add origin https://github.com/Showkath/helloSAPUI5CF.git
- git push -u origin main
For more details refer https://guides.github.com/
Note : You can run normal cd commands from SAP Business Application terminal to navigate to folders
cd.. = to navigate to one step back
pwd = which gives present working directory or location
Here are few useful git commands
SAP Business Application Studio also supports UI for various Git operations
Download ,import ,export Project code, files from SAP Business Application Studio
- You can download selected files or entire project to your local machine
- You can upload multiple files from your local machine to your space project desired folders in SAP Business Application Studio
Just right click with mouse on project or file you will get context menu in SAP Business Application Studio
You can upload multiple files from your local machine to your space project desired folders in SAP Business Application Studio
Select files from you local machine i,e from your system
hope this blog post helps