GIT_BRANCH_MERGE Function

Merges a Git branch into the currently checked-out branch.

Category:Git
See:For more information, see Using Git Functions in SAS.
If you previously used the GITFN_ functions, see Deprecated Git Functions.

Syntax

GIT_BRANCH_MERGE( 'directory', 'branch-name', 'author-name', 'author-email'<, remote>)

Required Arguments

'directory'

specifies the pathname of a local repository on the SAS server.

'branch-name'

specifies the branch that is merged into the currently checked-out branch.

'author-name'

specifies the author’s name for the branch merge.

'author-email'

specifies the author’s email for the branch merge.

Optional Argument

remote

indicates if the target branch is a remote branch or local branch.

1

indicates that the target branch is a remote branch.

0 or NULL

indicates that the target branch is a local branch.

Details

Overview

The GIT_BRANCH_MERGE function merges a specified Git branch into the currently checked-out Git branch. If a fast-forward merge is acceptable, the GIT_BRANCH_MERGE function automatically performs the fast-forward merge. If a fast-forward merge is not acceptable, the GIT_BRANCH_MERGE function creates a merge commit. The GIT_BRANCH_MERGE function uses the local branch by default. If your target branch is a remote branch, specify the value 1 for the optional argument remote. You can explicitly indicate the target branch is a local branch by specifying the value 0 for optional argumentremote.

Return Codes

The GIT_BRANCH_MERGE function has return codes that indicate whether the function was successful.

Return Codes

Return Code

Description

–2

Indicates that the index has conflicts. Check the log for conflicting files.

–1

Indicates that the merge failed. Check the log for additional details.

0

Indicates that the merge was successful.

1

Indicates that the branch was already up-to-date.

Example

data _null_;
 rc = git_branch_merge(
  "C:\User\Local_Git_Repo",        /*1*/ 
  "your-target-branch",           /*2*/ 
  "your-author-name",             /*3*/ 
  "your-author-email");           /*4*/ 
 put rc=;                         
run;                              
  1. Specify the pathname of your local Git repository.

  2. Specify the name of the branch that is merged into your currently checked-out branch. To check out a different branch, use the GIT_BRANCH_CHKOUT function.

  3. Specify the name of the author for the merge that appears in the commit history.

  4. Specify the email of the author for the merge that appears in the commit history.

The preceding statements produce these results:

NOTE: Merge 'your-target-branch' into current branch 'your-current-branch' successful.
 rc=0
Last updated: April 14, 2026