I wanted to revisit the basic use of Git because there have been several changes in the last six months to make it easier to use, as well as changes in the SAP Cloud Platform.

I’m glad the topic is getting some exposure — thanks to Kiran for her recent blog on the topic, especially a view in the SAP Cloud Platform cockpit showing how to create a new version of an application from a specific commit. Still, there are a few additional things to show, including multi-developer scenario.

Want to watch?

Below I will spell out the steps, but here’s a fresh 3-minute video that shows the complete steps for starting working with Git in a multi-developer scenario.

How to work with Git

Developer 1

Here’s the workflow for the first developer (with tips along the way).

  1. Create a Git repository. This can be in Github or in a Git system in your company. For our example, we create a Git repository in the SAP Cloud Platform.
    Creating a Git repository in SAP Cloud Platform is now simpler. You no longer have to create an application to get a Git repository, nor from SAP Web IDE do you have to create a project and deploy it. In SAP Cloud Platform, just go to the cockpit and select Repositories Git Repositories, and create one by clicking New Repository. Click on your new repository and get the clone URL for later.
  2. Create a project. In SAP Web IDE, create a project, for example, from a template.
  3. Initialize a local repository. Make your project a local Git repository by right-clicking the project in the workspace, and selecting Git Initialize Local Repository.
  4. Set remote repository. Here’s where you connect your local repository in Step 3 to the remote repository you created in Step 1. Click on Set Remote, either in the notification you get after initializing, or in the Git menu. 
  5. Rebase. Get the latest commits.
    If you don’t rebase, you’ll have trouble pushing later. A common problem I had was that on my first commit I could not push (the dreaded FAST FORWARD error), even though I knew my repository was empty. But in fact the repository has an automatic first commit, and you need to retrieve it. (When you create the Git repository in SAP Cloud Platform, you are asked if you want a first commit — it’s on by default.)
  6. Stage, commit, and push.
    I often forget to add a commit message and then wonder why the Commit button is disabled.

Developer 2

Now a second developer is interested in working on the project.

  1. Clone the repository. Get the clone URL from the first developer, and go Clone Git Clone Repository. The clone dialog is much simpler, and now you only need a clone URL. You can also select whether your repository works with Gerrit for code checking. More on Gerrit in another blog.
  2. Code. Make changes to the project as necessary.
  3. Stage, commit, and push.

Developer 1

Back to the first developer, who wants to get the latest changes.

  1. Fetch. Fetching brings back information about the remote repository — like what branches there are and what commits you are missing — but it does not update your project in the SAP Web IDE.
  2. Rebase. Rebasing updates your project with all the changes in the remote repository made by other developers (and that you already brought back with the Fetch command).

That’s it. In upcoming blogs, we’ll go through what happens when there are conflicts, and how to use Gerrit for code review and collaboration.

 

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Ram Ganti

    Hi Daniel,

    Thank you for your post. Its helpful.

     

    I have two trail accounts. In one trail account, I have created GIT repository and stored sample project created in that account.

    I tried to clone  the same repository in other trial account, I got error as “Service not enabled”.

    Please can you help me to understand the issue.

    (0) 

Leave a Reply