Core git-flow

class gitflow.core.GitFlow(working_dir='.')

Creates a GitFlow instance.

Parameters:working_dir – The directory where the Git repo is located. If not specified, the current working directory is used.

When a GitFlow class is instantiated, it auto-discovers all subclasses of gitflow.branches.BranchManager, so there is no explicit registration required.

checkout(*args, **kwargs)

Checkout a branch of the given type, with the given short name.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
Returns:

The checked out git.refs.Head branch.

create(*args, **kwargs)

Creates a branch of the given type, with the given short name.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
  • base – The alternative base to branch off from. If not given, the default base for the given branch type is used.
Returns:

The newly created git.refs.Head branch.

diff(*args, **kwargs)

Print the diff of changes since this branch branched off.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
finish(*args, **kwargs)

Finishes a branch of the given type, with the given short name.

Parameters:
  • identifier – The identifier for the type of branch to finish. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to finish.
has_staged_commits(*args, **kwargs)

Returns whether or not the current repo contains local changes checked into the index but not committed.

is_dirty(*args, **kwargs)

Returns whether or not the current working directory contains uncommitted changes.

is_merged_into(commit, target_branch)

Checks whether commit is successfully merged into branch target_branch.

Parameters:
  • commit – The commit or branch that ought to be merged. This may be a full branch-name, a commit-hexsha or any of branch-, head-, reference- or commit-object.
  • target_branch – The branch which should contain the commit. This may be a full branch-name, or any of branch-, head- or reference-object.
list(*args, **kwargs)

List the all branches of the given type. If there are not branches of this type, raises Usage with an explanation on how to start a branch of this type.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • arg0_name – Name of the first argument for the command line to be put into the explanation on how to start a branch of this type. This typically is name or version.
  • verbose – If True, give more information about the state of the branch: Whether it’s ahead or behind it’s default base, may be rebased, etc.
  • use_tagname – If True, try to describe the state based on the next tag.
name_or_current(*args, **kwargs)
Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – If the name is empty, see if the current branch is of type identifier. If so, returns the current branches short name, otherwise raises NoSuchBranchError.
  • must_exist – If True (the default), raises NoSuchBranchError in case no branch exists with the given name.

Otherwise return the name unchanged.

nameprefix_or_current(*args, **kwargs)
Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • prefix – If the empty, see if the current branch is of type identifier. If so, returns the current branches short name, otherwise raises NoSuchBranchError.

If exactly one branch of type identifier starts with the given name prefix, returns that branches short name. Raises NoSuchBranchError in case no branch exists with the given prefix, or PrefixNotUniqueError in case multiple matches are found.

publish(*args, **kwargs)

Publish a branch of the given type, with the given short name, to origin (or whatever is configured as remote for gitflow.)

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
pull(*args, **kwargs)

Pull a branch of the given type, with the given short name, from the given remote peer.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • remote – The remote to pull from. This must have been configured by git remote add ....
  • name – The friendly (short) name to create.
rebase(*args, **kwargs)

Rebase a branch of the given type, with the given short name, on top of it’s default base.

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
  • interactive – If True, do an interactive rebase.
require_no_merge_conflict(*args, **kwargs)

Raises MergeConflict if the current working directory contains a merge conflict.

track(*args, **kwargs)

Track a branch of the given type, with the given short name, from origin (or whatever is configured as remote for gitflow.)

Parameters:
  • identifier – The identifier for the type of branch to create. A BranchManager for the given identifier must exist in the self.managers.
  • name – The friendly (short) name to create.
  • base – The alternative base to branch off from. If not given, the default base for the given branch type is used.
Returns:

The newly created git.refs.Head branch.

Previous topic

Reference guide

Next topic

Branches