Git with SAP Business Application Studio

This post is about initializing a local git repository for an existing SAP Business Application Studio project and connecting it to a new remote GitHub repository.

This is applicable when you create a new project from template and want to backup your changes done.

Differences comapring to SAP WebIDE FullStack Git Management:

  • No option in the menu for Rebase operation using built-in Git Source Code Management UI within Business Application Studio.

For first time use Business Application Studio with GitHub:
please generate a Personal Access Token (called Business Application Studio) on your GitHub.com account. This token will serve as your Password when connecting BAS to GitHub. Official ducumentation can be found here. Select the following options for the token:

Save the token string in notepad temporary after creation, we’ll need it during setup.

Stay on github.com and create a repository.

For the sake of simplicity, the repository is called zgit in this demo.

Copy your repository url

https://github.com/attilaberencsi/zgit.git

to your favorite text editor, and switch back to SAP Business Application Studio.

Open context menu for your project to start a terminal in that folder. For the sake of simpicity my project name is zgit .

As first step, your GitHub email and username needs to be configured in Business Application Studio.

git config --global user.email "mygithubemailaddress@domain.xyz"
git config --global user.name "githubusername"

Next we initialize our local repository in Business Application Studio.

git init

Now we need to do the Staging operation manually. Period means every changes.

git add .

Commit your changes to your local repository

git commit -m "Project generation from template"

Now here comes the trick. We have local repo in Business Application Studio and a remote repo on GitHub, and we operate also with branches. We need create the branches and link them together. On GitHub we use main as branch in our example, but you can use master if you want.

As last operation, we do push our previosuly committed changes on local repository (BAS) also to the remote repository (GitHub), to keep the two Git repositories in sync.

git remote add origin https://github.com/attilaberencsi/zgit.git
git branch -m main
git push -u origin main

You’ll be prompted to enter your GitHub credentials in form of username and personal token you generated previously.

To make the work more convenient, you can set a timeout for your credentials in milliseconds.

git config credential.helper cache –timeout=7200000
git config credential.helper store

When working with templates in Business Application Studio, a README markdown file to the project is added automatically.

I remember spending quite some time with base and additional important notes for the UI5 application in form of readme.md files using SAP WebIDE, and generating a nicely formatted JSDoc3 document from it. Now we have a tiny little helper, great. Check this out in your github.com repo. Output looks great.

You can now switch to the assisted source code operations in Business Application Studio. Do a change in one of the files, and it will become automatically visible in the Git Pane

Do the Staging manually, so that your modifications in your workspace are ready to be recorded and commited to your local repository.

Enter some comments about your modification into the message field and do the actual Commit

Now your workspace is clean, the changes are recorded in your local repsoitory. We need to do a sync to update the remote repository on GitHub.

Do Push using the built-in operations pane.

As you can see, the common operations can be found in the pane.

Hint

You most probably switch workspaces containing one or more projects. To switch the git repository – managed by the Git Source Code Control tool of SAP Business Application Studio – use the button in the bottom left corner.

As result the command field shows the git repositories you’ve configured previously. Select the one you want controlled by the source code control tool built-into BAS.

Have fun with Business Application Studio đŸ˜‰