As an administrator, you can work with on-premise Git repositories once an appropriate destination has been created in your subaccount.
Connecting to a Public Git Repository
Using
SAP Business Application Studio, you can connect to all public git services, such as GitHub, GitLab, and GitBucket.Connecting to a Public Git Server that Requires a Certificate
You can manage the connectivity to a public Git server that requires a client certificate.
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
Tip: 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) Connect to Your Corporate Git System
4) How to cache Username & Password (Token) in SAP Business Application Studio
5) Create a new repository on GitHub
6) Clone existing repository in SAP Business Application Studio from GitHub Url
7) How to Push your code to GitHub in SAP Business Application Studio
8) How to Clone a Specific Branch from Git
9) Fetch latest code from specific branch
10) Switch to a specific branch
11) Create new Application in SAP Business Application Studio and Push application to GitHub
12) How to Push an Existing Project or New Project to Existing GitHub Repository
13) Other Git Operations like Pull Request (PR)
14) Troubleshooting
15) UI
16) 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 "x@users.noreply.github.com"
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 Githubfor example,john.test@sap.comotherwise your code push failsInstead of entering your private email address you can enter public profile email addressNote: 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 erroryou can enter public profile email address from your Github account1.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 commandsThe command “git config –list”will list the settings, repository detailsThere you should also find user.name and user.email.To know the username, type: git config user.nameTo know the email, type: git config user.email2) Password for your Github account
As of now SAP Business Application studio support Personal access tokens instead of passwordsTo use git in a SAP Business Application Studio (BAS) you should create an access token on github.x --> (settings -> developer settings -> personal access tokens) with the scope "repo"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 HTTPSPersonal 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 HTTPSYou should create a personal access token to use in place of a password with the Github UI or with the command lineTo create a token, follow the instructions described in the GitHub documentationReferencehttps://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/crea...How to create personal access token1)In the upper-right corner of Github page, click your profile photo, then click Settings.2)Click Developer settings3)Click Personal access tokens4)Click Generate new token5)Give your token a descriptive name (What’s this token for?)6) Select the scopes "repo" , 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 lineFor example, on the command line you would enter the following:$ git clonehttps://github.com/username/repo.gitUsername: your_usernamePassword: your_tokenScreenshotsGo 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.x.corp/settings/tokens3) Connect to Your Corporate Git System
Below configuration is not for opensource github or gitlab .It is for your actual corporate/enterprise Github system.See Connect to Your Corporate Git Repository for more information on using a destination with Cloud Connector as your GITon-premise setup ->Usually this configuration will be be done by your organization cloud admin for SCP Cloud Foundry sub-account level & it isone time setup/activityi.eevery developer no need to perform this configuration. So this connectivity should be setoncefor each new consumer account. Once it is set, all developers working in this consumer account can enjoy from it without an additional setupFor example:If you would like to connect to github.x. with SAP Business Application Studiofrom public internet or SCP Trail accountyou need to followConnect to your Corporate Git Systemas the github.x can't be reached from the public internet.- github.x. on premiserequiresconfiguring cloud connector in the account and adding a dedicated destination.
- To configure cloud connector please refer to the official documentation:
https://help.sap.com/viewer/9d1db9835307451daa8c930fbd9ab264/Cloud/en-US/d54ddfc1bc4f45b19dabfa09507...Just for your reference cloud connector & BTP Destination looks like as below
Note:#1) if you don't configure & clone your corporate Github Url in SAP Business Application Studio then you will get500 error ,unable to access .The requested URL returned error : 500#2) If you get error fatal: unable to access github 'https://github.x.corp/x/x.git/': Received HTTP code 502 from proxy after CONNECTThen try configure proxy or unsetThen i tried below proxy commands from terminalgit config --global http.proxy "http://proxy:xyourcorportateport"orgit config --global --unset https.proxygit clonehttps://github.x/x/x.git4) 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 repositoryAs SAP Business Application studio supportsgit commandsyou can user credential helper to store your credentials which is similar how your credentials stored in Windows machine àcredential managerin the same way application studio cache your credential instead of retype username & password .I think you have below optionsSAP Business Application Studio recently released new feature that while you are cloning project ,it will ask to enter email & personal access token . Then you can choose below option to save your credentials ( email , personal access token in your workspace
Below Previous approaches are obsolete i.e with above new feature of saving credentials you no need to follow below approaches1) .netrc in SAP Business Application Studio2) ...or Git Credential helperOption1:.netrc in SAP Business Application StudioTo save your Git personal access token in yourDev spaceYou just need to create a .netrc file in the $HOME directory & add below syntax .You can create this ".netrc" file either using UI or commandsSteps for UI Approach- In Application Studio click on File Menu & Open WorkSpace -> Select "User" workspace & click on Open

2. Right click & select create new file(orpress Alt N from keyboard ) in root directory USER
Enter file name as .netrc
3.Add the following content as per your github.corpmachine <git_host>login <user_id>password <user_github personal access token>Detailsmachine name: As your corporate Git hub url without protocol "https:/"login: As your corporate Github Emailidpassword: Your User organization Github personal access tokenTo know your token Refer above section2) Password for your Github accountin this blog postFor example machine github.comlogin john@myorg.compassword 825270ffffe74d9f988a0f0066ad59f0
Reference:https://help.sap.com/doc/47f5ed8a96a04b619d3c1724922b4151/Cloud/en-US/Wing_public.pdfOption2 :Git Credential helperEnter below commands once you login successfully when you push first time from Terminalgit config credential.helper cache –timeout=3600000git config credential.helper storeHear : 3600000 milliseconds equals to 60 minutesTo erase credentials use below command i.e to disable this cached username/password for your current local git folder, simply entergit config credential.helper ""
5) 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 tohttps://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. hearhttps://guides.github.com/
Below are git commands you can execute in “SAP Business Application Studio” à Terminal
Instruction generated in Github

6) 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

...or alternately you can also useCommand 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


7) How to Push your code to GitHub in SAP Business Application Studio
Just for simplicity i have added one file & then pushed file to git hub repository cloned abovehttps://github.com/Showkath/helloSAP.git
Don’t git push straight to master. Branch it out!Always Pull Before a Push. Doing so will ensure that your local copy is in sync with the remote repository.Remember, other team members have been pushing to the github remote and if you push before syncing up,you could end up with multiple heads or merge conflicts when you push. Before you try to push code out to the repository,you should always pull all the current changes from the remote repository to your local machine.To create a branch, run git branch -b <branch_name>. The command git branch -a lists all the available branches, and you can navigate among them using git checkout <branch_name>.A cool trick is to use git checkout - to switch back to the previous branch.You can also create branch in github or via git commands & push you code to that branchAs said best practice to use always pull before a pushwith below commandgit fetchorgit fetch -allRefer Miscellaneous Section for more details in this blog & Please explore more about git fetch , git pull, git stash over web orgit commandsYou need to execute below 4 commands from terminal to push your changesgit statusgit add .git commit -m "type your sample commit message about commit hear"git push -u origin devHeardevis 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.Tip: 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/docs8 How to Clone a Specific Branch from Git
To Create a new branchgit branch new-branch
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 commandsgit clone <repository url?git clonehttps://github.com/SAP/openui5-sample-app.gitgit branch <branchname>Example : git branch --karma-testHow to Clone a Specific BranchNow let's clone a specific branch from Github repository. There are two ways to clone a specific branch. There are two optionsoption1 :git clone --branch<branchname> <remote-repo-url>Example : git clone --branch devhttps://github.com/This automatically configures release-0.23 as the local branch but still tracks other branches.oroption2 :git clone ----branch <branchname> ----single-branch <remote-repo-url>Example : git clone ----branch release-0.23 ----single-branchhttps://github.com/SAP/ui5-webcomponents.gitThis 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 --branchgit clone --b <branchname> <remote-repo-url>Tip: 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/docs9) Fetch latest code from specific branch
To Pull latest source code from specific branchSyntax: git pull origin <branch-name>First make sure you are in branch that you don't want to pull.For example if you have master and development branch, and you are trying to pull develop branch then stay in master branch.git checkout mastergit pull origin development10) Switch to a specific branch
You can use git checkout or switch commandWhen your team working on a project, you are team members probably managing many different branches in your repository. As the number of branches grow, developers may need to work on different tasks in parallel, so you may need to switch branches very frequently.Before creating/switch view all the branches that exist in the repo.#1) git branchOutput:*masterdevelopmentfeature1#2)Switching Between BranchesYou can use git switch or checkout . Currently switch not supported hear . So please try git checkout commandSYNTAX: git checkout <branch-name>Example :git checkout new-branchorSYNTAX: git switch <branch-name>orYou can also clone in other folder git clone --branch branchnamehttps://github.x.x.x.gitLet’s suppose there is an existing branch called develop and we want to switch from master to develop branch. To do that execute:git switch developmentTo switchback to mastergit switch masterLet’s suppose if you would like to create a new branch which doesn’t exist and also at the same time we want to switch to it. For thatgit switch -c new-branch-nameorgit branch new-branch-namegit switch new-branch-name--------To switch to a remote branchIn order to switch to a remote branch, make sure to execute “git fetch” first.You can then switch to it by executing “git checkout” with the “-t” option and the name of the branch or git switchgit fetchgit checkout -t <remote_name>/<branch_name>orgit switch -c <branch> --track <remote>/<branch>Reference:https://git-scm.com/docs/git-switch11) Create New 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 tutorialsQuestion) What Kind of applications I can build using SAP Business Application Studio?https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-business-app...Or you may have followeddevelop 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 Studiohttps://developers.sap.com/group.cp-ui5-first-app.html#Create a Web Front End with SAPUI5https://developers.sap.com/group.cp-frontend-ui5-1.html# Deploy Your First SAPUI5 App to Cloud Foundryhttps://developers.sap.com/tutorials/appstudio-sapui5-create.html# Create an SAP Fiori App Using SAP Business Application Studiohttps://developers.sap.com/tutorials/appstudio-fioriapps-create.html# How to develop Fiori App in SAP Business Application Studiohttps://www.saplearners.com/how-to-develop-fiori-app-in-sap-business-application-studio/# All Tutorials/Exercises :https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-business-app...--------------------------------------------------------------------------------------------------------------------------------------Once project is ready now you would like topush project to Github,please follow below stepsPlease 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 initI follow this easy approach I.e I will create empty repository with same name I have given for projectfor example :helloSAPUI5CF - Please follow “Create a new repository on GitHub”in above section ingithubor your corporategithub.mycompany.com

- Execute below commands from your project root directory in SAP Business Application Studio Terminal
- cd projects
- cdhelloSAPUI5CF
- git init
- git add .
- git commit -m "my SAPUI5 CF first commit"
- git branch -M main
- git remote add originhttps://github.com/Showkath/helloSAPUI5CF.git
- git push -u origin main
Note : Here main is your branch name12 ) How to Push an Existing Project or New Project to Existing GitHub Repository
Lets say you need to push new project which you have created in SAP Business Application Studio to old git repository which is already exist in Github i.e if your project in BAS & GitHub both are independent then execute below commands- git init
- git add-A
- git commit -m "my first commit comments'
- git remote add originhttps://x.git
- git push -u origin main
Note : Here please replace above with your github http url &mainis your git repo existing branch nameJust additional details about commands :git add -A stages all changesgit add . stages new files and modifications, without deletions (on the current directory and its subdirectories).git add -u stages modifications and deletions, without new filesgit add -A is equivalent to git add .; git add -u.You can check your git remote to see where it is pointing to by executing below commandgit remote -v13) Other Git Operations
For more details referhttps://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
Tip: 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
Here are few useful git commands

Miscellaneous Section
Git pull = Git fetch + additional action(s),typically a Git merge
Every time you run git pull with uncommitted changes could get you into trouble
git fetch
git merge origin/$CURRENT_BRANCH
merge the changes from the remote repository that are not already present in your local checked out branch
Git fetch is a safer because it pulls in all the commits from your Github remote
without actually making any local changes to your work in your local branch
One thing to note is that by default, git fetch will only bring you changes from the current branch.
To get all the changes from all the branches, use git fetch --all.
And if you'd like to clean up some of the branches that no longer exist in the remote repository, git fetch --all --prune will do the cleaning up!
When your uncommitted changes are significant to you & you very much care about the Local Changes
git stash : To save your un-committed changes in a "stash"
git stash list:To list your saved stashes
git stash apply:apply stash to working tree in current branch
git stash apply stash@{x}
Example: git stash apply stash@{2}:if you will have many stashes you can choose what stash will apply -- in this case we apply stash 2
git stash branch: To create a new branch to apply your stashed changes to.
For example
git stash branch master_stash_newBranch stash@{1}
Git is powerful. Please explore more about git over web or git commands
14) Troubleshooting
Find here common solutions to frequently occurring issues.- Dealing with Git Merge Conflicts and Discarding Local Changes
Have you ever found yourself in a situation where you encounter a merge conflict on the main, master, or any of your feature branches, and you want to not only resolve the conflict but also completely discard any local changes you've made? Well, worry not, as there's a solution for that!Solution 1: Merge Conflict Resolution and Local Changes DiscardIf you're facing a merge conflict and want to clear out all your local changes, follow these steps:First, fetch all the latest changes from the remote repository using:git fetch --all
Next, reset your branch to match the remote main branch (or whichever branch you're working on). This will effectively wipe out any local changes:git reset --hard origin/main
If you're dealing with a different branch (replace 'yourbranchname' with the actual branch name):git reset --hard origin/yourbranchname
Important Note:Please be cautious when using these commands, as they will reset your branch to match the remote branch, erasing all local changes. This means it will remove all traces of your last commit.By following these steps, you can effectively resolve merge conflicts and start with a clean slate, ensuring your working directory matches the remote branch you're working on.2.Git Pull Error: If you face below error .The following untracked working tree files would be overwritten by merge: xPlease move or remove them before you merge.AbortingSoluition: Error is due to your local changes to repository that is, your modified files in your working directory .One Solution could be clear tracked files by using below commandgit clean -d -f
then try git pull Before executing aboveclean command ,if you need to take a back of your files, source code & stage them using git stash3)Github : Merge Button is not enabled i.e Requests stuck in "Checking ability to merge automatically" ,Never disappeared to Merge On all of the pull request (PR) merge requests the "Checking ability to merge automatically" icon appeared . In most instances, after a few minutes, and after refreshing the page, it finally went away. It appeared to go away after the build and pipelines had been completed but if it never disappeared below solution may help youExecute below commands from Terminal or Gitbashlets say your reviewer would like to review & merge "YourBranchName" to master but " Merge" but not enabledStep1 :git fetch origingit checkout -b "YourBranchName" "origin/YourBranchName"git merge "master"Step 2 :git checkout "master"git merge --no-ff "YourBranchName"git push origin "master"After executing above commands "YourBranchName" will be merged to master, you can also verify in Github15) UI
SAP Business Application Studio also supports UI for various Git operations

16) Download ,import ,export Project code, files from SAP Business Application Studio
- You can download entire project as atarfrom one Dev Space of BAS to import into other Dev Space
2. You can also download selected files or entire project to your local machine3. You can upload multiple files from your local machine to your space project desired folders in SAP Business Application StudioScreenshots Just right click with mouse on project or file you will get context menu inSAP 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
Upload ZIP Archive / Compress file & extract in SAP Business Application studioSAP Business Application Studio will provide different options to resolve any Usecase. If you would like to upload folder (without using Git) one solution is- Compress ZIP folder
- Create new folder in SAP Business Application studio with same name as ZIP file name
- Upload ZIP Archive file to desired folder
- Open Terminal in SAP Business Application Studio
- Navigate to newly created folder or where you would like to extract . You can use “cd (“change directory”)” commands from terminal
- Then extract folder / unzip in SAP Business Application Studio terminal with below command.
unzip yourfoldername.zipScreenshots for your reference





Open Terminal in SAP Business Application StudioNavigate to newly created folder or where you would like to extract . You can execute “cd (“change directory”)” commands from terminal
Then extract folder / unzip in SAP Business Application Studio terminal with below command
Later you can delete ZIP file (Right Click on ZIP file & choose Delete)Tip : How to delete project from SAP Business Application studio ?Either you can right click on Project folder & choose Delete from context Menu or you can use rm commandsOption1) Delete option using Context MenuIf you have single project opened as workspace you don't get "Delete" option. For this you need to open workspace & choose Projects
Then Rightclick on Project which you would like to delete , you will get menu & choose Delete
Hope this blog post helps