Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
yossi_balan
Explorer
Often you want to get the history of your commits – to reuse a change in another branch or to investigate changes someone else made.

In the Git History pane, you can see the commit history for a specific branch.

Access the pane by clicking the Git History pane icon [19]. The history is contextual, meaning the history of the selected file is displayed. To see the entire branch history, select the project root folder [20]. When selecting a commit, you can see additional information, such as the author [21] and the names of the files that were committed [22].

The Git History pane opens with the history of the checked-out branch. To see the commit history for a different branch, select it from the drop-down list [23]. This will not check out your branch, it will just display the history.


Check Out Commit from Branch’s History


You can check out a new branch from a specific commit in another branch’s history. This is helpful, for example, when you want to test an app before making changes .

To do this, you must select the commit that you want to check out and click the Check Out button [24]. This creates a local branch. In the dialog box, provide a name for the branch [25] and click OK [26].



Now you can switch to the Git pane and verify that the checked-out branch in your repository is the one you just created based on the commit from the other branch’s history.

Let’s check out a commit (commit called my first change) on the newFeature branch. This commit was before the Add first for commit B  and add file to new branch. As you can see, the FileInNewBranch.js and FileInNewBranchforCommitB.js files do not appear in my workspace.


Git Cherry-Pick


Sometimes you want to port a single commit, for example, when you are performing a fix on a released version and you want to add a fix to the current version without porting also new/other development on that branch. Git supports this operation with the cherry-pick operation.

Before cherry-picking, check out the branch on which you want to apply the changes (and make sure you don’t have any changes in your staging area). Then, in the Git History pane, select the branch you want to cherry-pick the commit from, select that commit, and click Cherry-Pick. The change is applied on the checked-out branch.

In the example below, I performed 2 commits on the master branch Add first for commit B and add file to new branch change [27]. For Add first for commit B, I committed the changes in FileInNewBranch.js and for add file to new branch change I committed the changes in FileInNewBranchForCommitB.js. I want to port only the add file to new branch commit containing the FileInNewBranch.js file [28] to the branchFromHistory branch.

In the Git History pane, with the master branch selected, I selected the add file to new branch commit and press Cherry-Pick [29], and then confirm [30].



As you can see in my workspace, only the FileInNewBranch.js file was added to the branchFromHistory branch


Select Multiple Branches


You can select several branches in the Git History and  commits of the branches that you selected.
To do this, select History of Branch [31], choose the relevant branches, then press OK [32].



Tags

You can add information to a commit, for example, by tagging it. Do this to add information about a specific commit, or to indicate information about a release.

Select a commit and press the Tag button [33], insert a tag name [34], and press OK [35].



A tag icon is added to the commit description. Hover on the icon and a tooltip shows the tag name.



Revert

You can undo the changes you made in a commit. The revert operation doesn’t remove the commit from the git history but generates a new commit that undoes all the changes introduced in the original commit.

In the Git History pane, select the commit add file to the new branch (which had added the file FileInNewBranch.js) and press Revert [36].



A new commit is created whose description starts with Revert. The commit deletes the file FileInNewBranch.js.



 

 

 
2 Comments