GitService class

Service that wraps the git CLI with typed Dart models.

All methods that modify state accept an optional workDir parameter. If not provided the service falls back to the defaultWorkDir given at construction time (or the current directory).

Constructors

GitService({String? defaultWorkDir, String gitBinary = 'git'})

Properties

defaultWorkDir String?
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(List<String> paths, {String? workDir}) Future<void>
Stages files.
blame(String filePath, {String? rev, String? workDir}) Future<GitBlame>
Returns per-line blame information for a file.
branches({bool all = false, String? workDir}) Future<List<GitBranch>>
Lists branches. Set all to include remote-tracking branches.
checkout(String ref, {bool create = false, bool force = false, String? workDir}) Future<void>
Checks out a ref (branch, tag, commit).
cherryPick(String commit, {String? workDir}) Future<void>
Cherry-picks a commit onto the current branch.
commit(String message, {List<String>? files, bool all = false, bool amend = false, bool allowEmpty = false, String? workDir}) Future<GitCommit>
Creates a commit.
diff({bool staged = false, String? path, String? commit1, String? commit2, String? workDir}) Future<String>
Returns the diff output as a raw string.
fetch({String? remote, bool prune = false, String? workDir}) Future<void>
Fetches from a remote.
getRepoRoot(String path) Future<String?>
Returns the root of the git repository containing path, or null.
isGitRepo(String path) Future<bool>
Returns true if path is inside a git repository.
log({int? maxCount, String? since, String? until, String? author, String? path, bool oneline = false, String? workDir}) Future<List<GitCommit>>
Returns commit log entries.
merge(String branch, {bool noFf = false, bool squash = false, String? workDir}) Future<void>
Merges a branch into the current branch.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pull({bool rebase = false, String? workDir}) Future<void>
Pulls from the upstream branch.
push({String? remote, String? branch, bool force = false, bool setUpstream = false, String? workDir}) Future<void>
Pushes to a remote.
rebase(String onto, {bool interactive = false, String? workDir}) Future<void>
Rebases the current branch onto onto.
remoteAdd(String name, String url, {String? workDir}) Future<void>
Adds a remote.
remoteRemove(String name, {String? workDir}) Future<void>
Removes a remote.
remotes({String? workDir}) Future<List<GitRemote>>
Lists configured remotes.
reset(List<String> paths, {bool hard = false, bool soft = false, bool mixed = false, String? workDir}) Future<void>
Resets files or the branch pointer.
shortlog({String? since, String? workDir}) Future<List<AuthorStats>>
Returns per-author commit counts.
stash({String? message, bool includeUntracked = false, String? workDir}) Future<void>
Stashes current changes.
stashList({String? workDir}) Future<List<GitStash>>
Lists all stash entries.
stashPop({int? index, String? workDir}) Future<void>
Pops a stash entry.
status({String? path}) Future<GitStatusResult>
Returns the current repository status including branch tracking info, file changes, and stash count.
tag(String name, {String? message, bool annotated = false, String? workDir}) Future<void>
Creates a tag.
tagList({String? workDir}) Future<List<String>>
Lists tags.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited