Branches

Contains helper functions which allow to deal with git branches.

Functions and values

Function or valueDescription
checkout repositoryDir create branch
Signature: repositoryDir:string -> create:bool -> branch:string -> unit

Performs a checkout of the given branch to the working copy.

Parameters

  • repositoryDir - The git repository.
  • create - Set this to true if the branch is new.
  • branch - The new branch.
checkoutBranch repositoryDir branch
Signature: repositoryDir:string -> branch:string -> unit

Performs a checkout of the given branch to the working copy.

Parameters

  • repositoryDir - The git repository.
  • branch - The branch for the checkout.
checkoutNewBranch(...)
Signature: repositoryDir:string -> baseBranch:string -> branch:string -> unit

Creates a new branch based on the given baseBranch and checks it out to the working copy.

Parameters

  • repositoryDir - The git repository.
  • baseBranch - The base branch.
  • branch - The new branch.
checkoutTracked(...)
Signature: repositoryDir:string -> trackBranch:string -> branch:string -> unit

Performs a checkout of the given branch with an additional tracking branch.

Parameters

  • repositoryDir - The git repository.
  • trackBranch - The tracking branch.
  • branch - The branch for the checkout.
createBranch(...)
Signature: repositoryDir:string -> newBranchName:string -> commit:string -> unit

Creates a new branch from the given commit.

Parameters

  • repositoryDir - The git repository.
  • newBranchName - The new branch.
  • commit - The commit which git should take as the new HEAD. - can be HEAD, HEAD~1, ... , a branch name or a prefix of a SHA1.
deleteBranch repositoryDir force branch
Signature: repositoryDir:string -> force:bool -> branch:string -> unit

Deletes the given branch.

Parameters

  • repositoryDir - The git repository.
  • force - Determines if git should be run with the force flag.
  • branch - The branch which should be deleted.
deleteTag repositoryDir tag
Signature: repositoryDir:string -> tag:string -> unit

Deletes the given tag.

Parameters

  • repositoryDir - The git repository.
  • tag - The tag which should be deleted.
findMergeBase(...)
Signature: repositoryDir:string -> commit1:string -> commit2:string -> string

Returns the SHA1 of the merge base of the two given commits from the given repository.

Parameters

  • repositoryDir - The git repository.
  • commit1 - The first commit for which git should find the merge base.
  • commit2 - The second commit for which git should find the merge base.
getAllBranches(repositoryDir)
Signature: repositoryDir:string -> string list

Gets all local and remote branches from the given repository.

getLocalBranches(repositoryDir)
Signature: repositoryDir:string -> string list

Gets all local branches from the given repository.

getRemoteBranches(repositoryDir)
Signature: repositoryDir:string -> string list

Gets all remote branches from the given repository.

getSHA1 repositoryDir commit
Signature: repositoryDir:string -> commit:string -> string

Returns the SHA1 of the given commit from the given repository.

Parameters

  • repositoryDir - The git repository.
  • commit - The commit for which git should return the SHA1 - can be HEAD, HEAD~1, ... , a branch name or a prefix of a SHA1.
pull repositoryDir remote branch
Signature: repositoryDir:string -> remote:string -> branch:string -> unit

Pulls a given branch from the given remote.

Parameters

  • repositoryDir - The git repository.
  • remote - The name of the remote.
  • branch - The name of the branch to pull.
push(repositoryDir)
Signature: repositoryDir:string -> unit

Pushes all branches to the default remote.

Parameters

  • repositoryDir - The git repository.
pushBranch repositoryDir remote branch
Signature: repositoryDir:string -> remote:string -> branch:string -> unit

Pushes the given branch to the given remote.

Parameters

  • repositoryDir - The git repository.
  • remote - The remote.
  • branch - The branch.
pushTag repositoryDir remote tag
Signature: repositoryDir:string -> remote:string -> tag:string -> unit

Pushes the given tag to the given remote.

Parameters

  • repositoryDir - The git repository.
  • remote - The remote.
  • tag - The tag.
revisionsBetween(...)
Signature: repositoryDir:string -> commit1:string -> commit2:string -> int

Returns the number of revisions between the two given commits.

Parameters

  • repositoryDir - The git repository.
  • commit1 - The first commit for which git should find the merge base.
  • commit2 - The second commit for which git should find the merge base.
tag repositoryDir tag
Signature: repositoryDir:string -> tag:string -> unit

Tags the current branch.

Parameters

  • repositoryDir - The git repository.
  • tag - The new tag.