云服务器价格_云数据库_云主机【优惠】最新活动-搜集站云资讯

文件存储_mysql连接服务器_试用

小七 141 0

In this blog post I describe two common Git flows (merge and rebase). I will purposely add conflicts to these flows so I can then show you how to resolve them and continue with the Git operation.

For the purpose of this demo, I created a simple Git repository (on GitHub.com) with a single remote master branch (origin/master).

In SAP Web IDE, I created two local branches based on the origin/master branch:

master (created automatically by SAP Web IDE when I cloned the repository) feature1

The Git repository contains a single file named sample.txt with the following content:

Now we will create the conflict as follows:

The sample.txt file appears in the staging table in the Git pane (now in the master branch).

Let’s recap… you modified the same code line in the same file but in two different branches and committed these changes to Git.

Now comes the interesting part…

Let’s assume that we want to incorporate the changes done in the feature1 branch to the master branch. There are 2 ways in which we can do this: rebase and merge.

You can read this excellent tutorial about the differences between merge and rebase.

We’ll start with rebase:

Let’s see what happens when we try to rebase.

While still on the master branch, click on Rebase in the Git pane, and select the feature1 local branch as the source for the rebase operation.

The following message appears:

Click OK.

Now the Git pane is in "Rebase Interactive" mode.

You can see that the sample.txt file is in conflict – the little red icon next to the file name indicates the conflict status .

To resolve the conflict, double-click the file in the staging table to open the Compare editor.

On the right, you can see the file from the source branch (feature1) and on the left you can see the file from the target branch (master). Row #3 is conflicting and we need to decide which value we want.

For the sake of this example, let’s assume that the correct value is the one coming from the feature branch (i.e. 555).

Click on the "Copy from right to left" button.

This will copy the 555 from the feature1 branch version to the master branch.

You can also manually edit the file on the left with a different value (yes, the compare editor is also editable).

Save and stage the file.

Click Continue in the Git pane.

Now you should be back to the standard view of the Git pane with your changes merged from feature1 to master.

You can now push the changes to the remote Git repository.

Now let’s see how this works when merging.

Repeat steps 1-13 in the previous section to recreate the conflict.

While still on the master branch, click on Merge in the Git pane, and select the feature1 local branch as your source for the merge operation.

Click OK.

The following message appears:

Click OK.

Now the Git pane is in "Merge Interactive" mode.

You can see that the sample.txt file is in conflict.

As we saw in the previous section, we can use the compare editor to fix and resolve this conflict.

However, I want to show you how this is done using the standard code editor.

Open the sample.txt file in the code editor by clicking the 3 dots in the staging table and selecting Edit.

This is what the file looks like in the code editor:

The code that was changed in the master branch appears under the > feature1 statement:

All we need to do now is to clean-up the code and leave only the text that we want to keep in our file. Let’s assume we want to keep the 555 form the feature1 branch. This is what the file should look like after our edit:

Save and stage the file.

Add a commit message and commit the change.

This is what the commit history looks like after the change was merged to the master branch:

You can now push the changes to the remote Git repository.

So what have we learnt?

We saw how easy it is to resolve conflicts using the SAP Web IDE Git pane.

You can do it using the Compare editor or by manually editing the relevant file in the code editor.

I hope you found this helpful. If there is another Git-related topic on which you would like to learn or get helpful tips, please let me know in the comments section below.

,云服务器服务好,物联网管理平台,大数据说,免费大数据,游戏返利