Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
53,486
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.

 
37 Comments
rkganthi
Explorer
0 Likes
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.
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
There is no supported use case where a user from one account will get access to a repository in another account. The use case I described was with 2 developers in the same account. You could of course use Github, but you essentially have the same issue -- you need to create an account in Github.
AbdelhalimDadouche
Active Contributor
0 Likes
 

Hi @rkganthi & @daniel.wroblewski,

 

This is actually feasible on trial as well.

 

In the past you use to have a dialog where you could enter your credentials, but in a trial scenario I wasn’t making sense as you would only use your GIT.

 

So the dialog is now simplified with just the remote source url only.

 

So to connect to a remote account GIT on trial, you will need to adjust the repository url and include the remote user id in it like this:

https://<remote scp user id>@git.hanatrial.ondemand.com/<remote scp user id>/<remote scp git repo name>

 

Then you should get prompted for the password for <remote scp user id>. Make sure you check “Remember password”.

 

Hope this helps.

 

@bdel
Former Member
0 Likes

Abdel.

 

This is exactly what i’m looking for.

 

I tried your suggestion, but when i Input the password for  <remote scp user id>, it does’nt work. It says “Not authorized”…

Just to clarify, the password im putting is the pasword for the <remote scp user id> user, the one i use to login to SAP HCP.  

Is there something i’m missing?

 

Thanks!

Ez

AbdelhalimDadouche
Active Contributor
0 Likes
Hi,

 

Let's say I'm user A with my Git repo name myrepo I want to share with you, let's call you user B.

 

So, from a WebIDE session under user B credentials, I would enter:

https://userA@git.hanatrial.ondemand.com/userA/myrepo


Then I will have to enter user A password when prompted.

 

It was working when I wrote the response, but I haven't tested it since then to be honest.

 

@bdel
Former Member
0 Likes
Thank you very much for your answer!

Yes, that's exactly what i'm doing, but i get the "Not Authorized" message...

May be it's not working anymore?

If it's not much asking.. when you have a minute could you try if it's working now? Just to discard that it's me doing something wrong.

Ez.
Former Member
0 Likes
HI ,

Is it possible to get Git Repository files and content ? other application ? we need any API support here ?

i will tell you my case:

i have one input files and button . in the input filed i give hcp git url  like https://git.hanatrial.ondemand.com/p1xxxxx/fioridemo.

after clicking submit button i need to get the "fioridemo" files and content in table .

i get succeed using github.com to get the user repository  files and content by using https://api.github.com/ API file.

 

is there any API file to get the HCP Git repository ?

 

please suggest me on this.:)

 

Regards,
Sam

 
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
OK, I thought you meant you had one user who had access to 2 SCP accounts. So in essence you have simply set up 2 trial accounts (with 2 different users) and do not grant permissions across accounts. Right?
michal_keidar
Advisor
Advisor
0 Likes
Unrelated question - how did you tag the persons in your comment?

Thanks 🙂
Former Member
0 Likes
HI ,

Is it possible to get Git Repository files and content ? other application ? we need any API support here ?

i will tell you my case:

i have one input files and button . in the input filed i give hcp git url  like https://git.hanatrial.ondemand.com/p1xxxxx/fioridemo.

after clicking submit button i need to get the “fioridemo” files and content in table .

i get succeed using github.com to get the user repository  files and content by using https://api.github.com/ API file.

 

is there any API file to get the HCP Git repository ?

 

please suggest me on this.:)

 

Regards,
Sam

 
AbdelhalimDadouche
Active Contributor
0 Likes
You can use the "at" sign with the user name ;-).

 
AbdelhalimDadouche
Active Contributor
0 Likes
yes, 2 trial accounts (with 2 different users). Then from one setup the GIT, and on the second use the first one credentials as mentioned earlier.

 

Let me know if it worked for you.
michal_keidar
Advisor
Advisor
0 Likes
@Abdel DADOUCHE - does it work? I don't think it works..

 
AbdelhalimDadouche
Active Contributor
0 Likes
It use to work 😞 @michal.keidar 
Former Member
0 Likes
Can you answer my question ?
AbdelhalimDadouche
Active Contributor
Hi,

 

Unfortunately, I didn't found any API exposed for GIT repositories hosted on the SAP Cloud Platform.

May be @daniel.wroblewskiwill have an answer.

Regards
Former Member
0 Likes
Hi,

Thanks for the return.

 

i'm also facing same issue with HCP Git , @Daniel Wrobleski or anyone can help here .

i'm able to get repositories from Github actually.

Regards,
Sam
michal_keidar
Advisor
Advisor
0 Likes
Please create a separate thread and use the relevant tags for it
Former Member
0 Likes
I tried this way sharing repositories between two trial accounts and it worked! Thanks a lot! 😃
VictorHo
Participant
0 Likes
Hello,

When I pull remote repository to my local branch in SAP Web Ide, I've got this problem with GIT:
3:13:49 PM (git) Pull request failed No merge base could be determined. Reason=CONFLICTS_DURING_MERGE_BASE_CALCULATION. "More than 200 merge bases for:
a ac84124fd128aa579db65693b36be11b5d9a3575
b 1b9e27eb78bed7f9ec40517fee32dfb0a5504ef7 found:
count 2"

I've searched but found no solution, the only solution is mentioned here.

They suggest to update the git version to higher version, but it seems unable to do so in sap web IDE. The Web IDE also does not support git command line so there's no solution to get over this bug.

Could you please support this case?

Thanks a lot!

Victor.
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
Hi Victor,

I have not encountered this problem. Can you do a Fetch and then a Rebase?

Daniel
VictorHo
Participant
Hi Daniel,

The git system has fixed the problem.

After getting the error, I've tried to Fetch then Rebase but I didn't work.

After sometimes, Git system has fixed the error (I'm not sure how) by merging all the changes into one commit. I've searched the Internet and the community mentioned that this is a bug from Git.

I hope we won't encounter this bug in the future.

Thank you!

Victor
0 Likes
Hi, when I try to clone the Git repository to my workspace from HCP, all I get is gitignore file. WebIDE console gives error (CloneandOpen) Path parameter not found. I cannot find any solution or description of the similar problem anywhere, do you have any idea why cloning git is not working for me?
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
It's tough to diagnose...can you provide screen shots and exactly what you did, and the exact message?
0 Likes
Hi, Daniel, I found the reason why it is like this - the GIT master branch link is empty, instead tree is visible and is located under the version tags. What could be done so I could get to the tree and clone it to webIDE?

Thanks!
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
uri.nizan Can you suggest an answer?

 
michal_tall
Advisor
Advisor
0 Likes
Hi Diana ,

I'm trying to understand your flow:
1. From the cockpit you go to Git Repository.
2. From the list of the git project you click on your project.
3. Then you copy the 'Repository URL'
4. From Web IDE you click on File > Git > Clone Repository
5. You paste the copied URL into URL filed and click on Clone.
6. And then what ? do you get an error message ? do you get your project tree ?

If it is possible please attach a screenshot and/or update the scenario.
Please specify what is expected and what is the actual result.

Regards,
Michal
EkanshCapgemini
Active Contributor
0 Likes
Hello Abdel,

I also tried your approach but even after entering the password of userA while cloning the userA's repository in userB's webide, it is not working. I am sure that I am entering the correct password.

Can you help in this?

 

Regards,

Ekansh
AbdelhalimDadouche
Active Contributor
Hi ekansh005

 

As @Michal Keidar remomended you should create a question for this.

 

At the time I provided my response it was working, but since then the WEB IDE and The GIT integration in SAP Cloud Platform may have change.

 

Regards

 

abdel.dadouche
former_member273190
Participant
0 Likes
Hi guys.

After using GIT in SAPWEBIDE, i'm having this issue for every single view that i try to open in Layout editor:



Testing with same project outside GIT it's working...

Any thoughts?

Thanks.

Mauricio

 

 

 
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes
michal.tall Do you know anything about this issue?

 
former_member273190
Participant
0 Likes
Hi.

 

Any news about the Git clone repository above?

 

Best regards.

 

Mauricio.
michal_keidar
Advisor
Advisor
0 Likes
Hi Mauricio,

First, please create a separate question for your issue, and not as a comment in a blog.

Second, I see from your screenshot that you're using the old version of Web IDE. Please use Web IDE Full-Stack, and if you're still having this issue, either open a support ticket (if you have a paid license), or create a new question.

Regards,
Michal.
swaroop_anasane
Active Contributor
0 Likes
mpred I confirm it's working on trail webide.

GIT on user A, cloned to user B, using credentials on user A.

Regards,

Swaroop
Former Member
0 Likes
Hi Daniel,

 

This is very helpful.

Can you tell me after this can we fetch this code  in Visual studio code with the help of SAP Git repository ?

If yes could you please tell me how to do this ?

 

 

Thanx

Sani.
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

  1. This was a while ago and I'm not with SAP Web IDE anymore, so I'm not so up to date.

  2. I'm sure there has been a lot of changes with the SCP Git functionality, as well as the way in SAP Web IDE for using Git (e.g., can create Git repository from within SAP Web IDE without going to cockpit).

  3. I'm not sure I understand the question: You mean can someone not logged into SCP access the Git repository? When I clone from a Git repository, I have to log into my SCP account.

  4. This tutorial is based on the Neo environment, which seems likely to be superseded by Cloud Foundry. I don't see repositories in CF.


Hope that helps a little 🙂