Pushing Changes to a Remote GIT Repository

Objectives

After completing this lesson, you will be able to:

  • Push changes from your local Git repository to a remote GIT repository

Work with a Remote Git Repository

Business Example

In this exercise, you will learn how to create and work with a remote Git repository.

As we have seen in previous exercise, SAP Business Application Studio has a local repository for GIT. However, the recommendation is always to have the work saved in remote repositories. Remote repository can be public or private (also knows as Corporate GIT).

For this exercise, we will focus on using the Public GIT in particular GitHub https://github.com/. You can use any other if you already have an account or are familiar with the tool.

Note
SAP BTP Platform and SAP Business Application Studio are cloud services. Due to the nature of cloud software, the naming of fields and buttons, as well as the content of the steps, may differ from the exercise solution provided here.

Steps

  1. If you do not have a GitHub account, visit https://github.com/ and create one. Make sure that you are using a valid email address. Furthermore, make sure that you are able to access the email account.

    1. Go to https://github.com/ and choose Sign up.

    2. Follow the account creation process step by step.

  2. Go to https://github.com/ and log into your account. Then create a new repository with the following information:

    Repository Information

    FieldValue
    Repository nameux402repository
    DescriptionRepository for UX402
    Repository visibilityPrivate
    1. In the upper-right corner of any page, use the plus(+) dropdown menu, and select New repository.

    2. Enter ux402repository as the Repository name.

    3. Enter Repository for UX402 as the Description.

    4. Choose Private as repository visibility.

    5. Choose Create repository.

  3. Create a personal access token with the listed information. After the creation of the personal access token, ensure you copy and save it because you will not be able to see it again and you will need to insert it into a file of the SAP Business Application Studio. You can create the personal access token in the Developer settings of your GitHub account.

    Personal Access Token Information

    FieldValue
    Noteux402
    Select scoperepo, delete_repo and write:discussion
    1. Open the personal settings of your account by clicking on your account in the upper right corner, and choose Settings from the dropdown menu.

    2. Choose Developer settings.

    3. Choose Personal access tokens.

    4. Choose Tokens (classic).

    5. Choose Generate new tokenGenerate new token (classic).

    6. Enter ux402 at Note and select repo, delete_repo and write:discussion at Select scopes. Choose Generate token.

    7. Make sure to copy and save your new personal access token now because you will not be able to see it again; you will need to insert it into a file of the SAP Business Application Studio.

  4. Log into your SAP BTP account and open the SAP Business Application Studio.

    1. Perform this step as shown in a previous exercise.

  5. Open the terminal for the ux402_repository folder. Set your email address and username for your Git account by executing the following commands:

    • git config --global user.email "<your github email address >"
    • git config --global user.name "<your github username>"
    1. Open the terminal for the ux402_repository folder. Set your email address and username by executing the listed commands.

  6. In order to save the personal access token within the SAP Business Application Studio, create a .netrc file within the /home/user folder with the listed information. Only one space is required between the key and the value.

    Content of the .netrc File

    KeyValue
    machinegithub.com
    login<Your GitHub email address>
    password<Your personal access token from step 2>
    1. Choose FileOpen Folder….

    2. Enter /home/user/ and choose OK.

    3. Choose the New File icon.

    4. Enter .netrc and press the Enter key (on your keyboard).

    5. Enter the listed key-value pairs. There is no need to use : or = for the key-value pairs. Only one space is required between the key and the value.

    6. It will look like what we see in the following figure:

    7. Save your changes.

  7. Open the ux402_repository workspace. Open the terminal for the ux402_repository folder and assign the new remote Git repository to your project. To assign the new remote Git repository to your project, you can use the following command with the URL of your ux402repository remote Git repository, which can be found on GitHub: git remote add origin https://<Git-Host-URL>/<full-path-to-repository>

    1. Choose FileOpen Recent … to go back to your projects.

    2. From the context menu of the ux402_repository folder, choose Open in Integrated Terminal.

    3. Within the terminal, execute the following command with the URL of your ux402repository remote Git repository, which can be found on GitHub: git remote add origin https://<Git-Host-URL>/<full-path-to-repository>

  8. Push the changes from your local Git repository to the remote Git repository. You can use the Push to… action from the Git view.

    Note
    If a window appears on the bottom right of your screen asking for periodical git Fetch, answer No.
    1. Open the Git view.

    2. Choose the three dots symbol (Views and More Actions…) and choose Pull, PushPush to…

    3. In the input field, choose origin.

    4. If the following window appears, answer/select No.

  9. Check the content of your remote Git repository on GitHub.

    1. Go to https://github.com/ and log into your account.

    2. Open your remote Git repository, ux402repository.

    3. Observe the content of your repository.

    4. To see the three commits, choose the clock symbol.

Log in to track your progress & complete quizzes