Skip to content

Latest commit

 

History

History
628 lines (465 loc) · 11.2 KB

File metadata and controls

628 lines (465 loc) · 11.2 KB

Git

  • class Git (git\Git)
  • package git
  • source git/Git.php

Description

Class Git


Methods


Methods

__construct()

__construct(string $directory, bool $createIfNotExists): void

Git constructor.


init()

init(bool $bare): void

resolve()

resolve(string $revstr): array

Parse a git revision string and return an object id.

  • Combinations of these operators are supported:

HEAD, MERGE_HEAD, FETCH_HEAD SHA-1: a complete or abbreviated SHA-1 refs/...: a complete reference name short-name: a short reference name under {@code refs/heads}, {@code refs/tags}, or {@code refs/remotes} namespace tag-NN-gABBREV: output from describe, parsed by treating {@code ABBREV} as an abbreviated SHA-1. id^: first parent of commit id, this is the same as {@code id^1} id^0: ensure id is a commit id^n: n-th parent of commit id idn: n-th historical ancestor of id, by first parent. {@code id3} is equivalent to {@code id^1^1^1} or {@code id^^^}. id:path: Lookup path under tree named by id id^{commit}: ensure id is a commit id^{tree}: ensure id is a tree id^{tag}: ensure id is a tag id^{blob}: ensure id is a blob


resolveCommit()

resolveCommit(string $revstr): string

getDirectory()

getDirectory(): File

getWorkTree()

getWorkTree(): File

getBranch()

getBranch(): string

getFullBranch()

getFullBranch(): string

getRemoteName()

getRemoteName(string $name): string

findRef()

findRef(string $name): array

Search for a ref by (possibly abbreviated) name.


exactRef()

exactRef(string $name): array

Get a ref by name.


getState()

getState(): string

SAFE, MERGING, MERGING_RESOLVED, CHERRY_PICKING, CHERRY_PICKING_RESOLVED, REVERTING, REVERTING_RESOLVED, REBASING, REBASING_REBASING, APPLY, REBASING_MERGE, REBASING_INTERACTIVE, BISECTING


isBare()

isBare(): bool

isExists()

isExists(): bool

getTags()

getTags(): array[]

setCredentials()

setCredentials(string $username, string $password): void

setTransportConfig()

setTransportConfig(array $config): void

Transport global config for push, fetch, pull, etc.

Config is an array:

timeout => int (seconds) dryRun => bool checkFetchedObjects => bool fetchThin => bool pushAtomic => bool pushThin => bool removeDeletedRefs => bool

sshPassword => string sshHost => string sshPort => int

sshIdentity => [privateKey => string, publicKey => string (optional), passphrase => string (optional)] sshKnownHosts => string or Stream (path to file)


remoteList()

remoteList(): array

remoteAdd()

remoteAdd(string $name, string $uri): array

remoteSetUrl()

remoteSetUrl(string $name, string $uri): array

remoteRemove()

remoteRemove(string $name): array

status()

status(array|null $paths, array|null $options): array

Status git command, options:

ignoreSubmoduleMode => string (ALL|DIRTY|UNTRACKED|NONE)

Return array value:

added => [...] changed => [...] conflicting => [...] ignoredNotInIndex => [...] missing => [...] modified => [...] removed => [...] uncommittedChanges => [...] untracked => [...] untrackedFolders => [...]


diff()

diff(array $options): array

Diff git command, options are:

cached => bool contextLines => int destPrefix => string sourcePrefix => string showNameAndStatusOnly => bool pathFilter => string


reflog()

reflog(string $ref): array

log()

log(array $options): array[]

Options are:

maxCount => int skip => int all => bool paths => string[] or string

range => [fromId, toId (nullable)]


branchList()

branchList(array $options): array

Return branches, options are:

listMode => string (ALL|REMOTE) contains => string (a commit ID or ref name)


branchCreate()

branchCreate(string $name, array $options): array

Create branch, options are:

force => bool startPoint => string (rev commit) upstreamMode => string (TRACK|NOTRACK|SET_UPSTREAM)


branchRename()

branchRename(string $newName, string $oldName): array

Used to rename branches.


branchDelete()

branchDelete(array $names, bool $force): string[]

Used to delete one or several branches.

The result of call is a list with the (full) names of the deleted branches.


add()

add(string $filePattern, array $options): void

Add git command, options:

update => bool


commit()

commit(string $message, array $options): array

Add git command, options:

all => bool allowEmpty => bool amend => bool insertChangeId => bool noVerify => bool only => string reflogComment => string

author => [name, email] committer => [name, email]


push()

push(string $remote, array $options): array[]

Push git command, options:

atomic => bool dryRun => bool force => bool all => bool tags => bool receivePack => string thin => bool timeout => int (millis) credentials => [username, password]


fetch()

fetch(array $options): array

Fetch git command, options are:

checkFetchedObjects => bool dryRun => bool removeDeletedRefs => bool thin => bool remote => string recurseSubmodules => string (YES|NO|ON_DEMAND) tagOpt => string (AUTO_FOLLOW|NO_TAGS|FETCH_TAGS) timeout => int (seconds) credentials => [username, password]


pull()

pull(string $remote, array $options): array

Pull command, options:

rebase => bool branch => string strategy => string (ours, theirs, resolve, recursive, simple-two-way-in-core) timeout => int (seconds) credentials => [username, password]


merge()

merge(array $revs, array $options): array

Options:

commit => bool message => string squash => bool fastForward => string (FF|NO_FF|FF_ONLY) strategy => string (ours, theirs, resolve, recursive, simple-two-way-in-core)


reset()

reset(array $options): array

Options are:

mode => string (SOFT|MIXED|HARD) ref => string disableRefLog => bool paths => string[] or string


clean()

clean(array $options): string[]

Clean git command, options:

cleanDirectories => bool dryRun => bool force => bool ignore => bool paths => string[]


rm()

rm(string $filePattern, bool $cached): void

checkout()

checkout(array $options): array

Checkout git command, options are:

allPaths => bool createBranch => bool force => bool orphan => bool name => string stage => string (BASE|OURS|THEIRS) startPoint => string (a commit ID or ref name) upstreamMode => string (TRACK|NOTRACK|SET_UPSTREAM) paths => string[] or string


stashCreate()

stashCreate(array $options): array

Stash create git command, options are:

includeUntracked => bool indexMessage => string ref => string workingDirectoryMessage => string


stashApply()

stashApply(array $options): array

Options are:

applyIndex => bool applyUntracked => bool stashRef => string strategy => string


stashDrop()

stashDrop(array $options): array

Options are:

all => bool stashRef => int


stashList()

stashList(): array

Stash list git command.