Git
Enhances the Git distributed version control system by providing aliases, functions and by exposing repository status information to prompts.
Git 1.7.2 is the minimum required version.
Settings
Log
The format of the git-log output is configurable via the following style,
where context is brief, oneline, and medium, which will be passed to the
--pretty=format: switch.
zstyle ':prezto:module:git:log:context' format ''
Status
Retrieving the status of a repository with submodules can take a long time. Submodules may be ignored when they are dirty, untracked, all, or none.
zstyle ':prezto:module:git:status:ignore' submodules 'all'
This setting affects all aliases and functions that call git-status.
Aliases
Git
gis short forgit.
Branch
gblists, creates, renames, and deletes branches.gbccreates a new branch.gbllists branches and their commits.gbLlists local and remote branches and their commits.gbslists branches and their commits with ancestry graphs.gbSlists local and remote branches and their commits with ancestry graphs.gbxdeletes a branch.gbXdeletes a branch irrespective of its merged status.gbmrenames a branch.gbMrenames a branch even if the new branch name already exists.
Commit
gcrecords changes to the repository.gcastages all modified and deleted files.gcmrecords changes to the repository with the given message.gcochecks out a branch or paths to work tree.gcOchecks out hunks from the index or the tree interactively.gcfamends the tip of the current branch using the same log message as HEAD.gcFamends the tip of the current branch.gcpapplies changes introduced by existing commits.gcPapplies changes introduced by existing commits without committing.gcrreverts existing commits by reverting patches and recording new commits.gcRremoves the HEAD commit.gcsdisplays various types of objects.gcllists lost commits.
Conflict
gCllists unmerged files.gCaadds unmerged file contents to the index.gCeexecutes merge-tool on all unmerged file.gCochecks out our changes for unmerged paths.gCOchecks out our changes for all unmerged paths.gCtchecks out their changes for unmerged paths.gCTchecks out their changes for all unmerged paths.
Data
gddisplays information about files in the index and the work tree.gdclists cached files.gdxlists deleted files.gdmlists modified files.gdulists untracked files.gdklists killed files.gdilists ignored files.
Fetch
gfdownloads objects and references from another repository.gfcclones a repository into a new directory.gfmfetches from and merges with another repository or local branch.gfrfetches from and rebases on another repository or local branch.
Grep
ggdisplays lines matching a pattern.ggidisplays lines matching a pattern ignoring case.ggllists files matching a pattern.ggLlists files that are not matching a pattern.ggvdisplays lines not matching a pattern.ggwdisplays lines matching a pattern at word boundary.
Index
giaadds file contents to the index.giAadds file contents to the index interactively.giuadds file contents to the index (updates only known files).giddisplays changes between the index and a named commit (diff).giDdisplays changes between the index and a named commit (word diff).girresets the current HEAD to the specified state.giRresets the current index interactively.gixremoves files/directories from the index (recursively).giXremoves files/directories from the index (recursively and forced).
Log
gldisplays the log.glsdisplays the stats log.glddisplays the diff log.glodisplays the one line log.glgdisplays the graph log.glbdisplays the brief commit log.glcdisplays the commit count for each contributor in descending order.
Merge
gmjoins two or more development histories together.gmCjoins two or more development histories together but does not commit.gmFjoins two or more development histories together but does not commit generating a merge commit even if the merge resolved as a fast-forward.gmaaborts the conflict resolution, and reconstructs the pre-merge state.gmtruns the merge conflict resolution tools to resolve conflicts.
Push
gpupdates remote refs along with associated objects.gpfforcefully updates remote refs along with associated objects.gpaupdates remote branches along with associated objects.gpAupdates remote branches and tags along with associated objects.gptupdates remote tags along with associated objects.gpcupdates remote refs along with associated objects and adds origin as an upstream reference for the current branch.gpppulls and pushes from origin to origin.
Rebase
grforward-ports local commits to the updated upstream head.graaborts the rebase.grccontinues the rebase after merge conflicts are resolved.grimakes a list of commits to be rebased and opens the editor.grsskips the current patch.
Remote
gRmanages tracked repositories.gRllists remote names and their URLs.gRaadds a new remote.gRxremoves a remote.gRmrenames a remote.gRufetches remotes updates.gRpprunes all stale remote tracking branches.gRsdisplays information about a given remote.gRbopens a remote on GitHub in the default browser.
Stash
gsstashes the changes of the dirty working directory.gsaapplies the changes recorded in a stash to the working directory.gsxdrops a stashed state.gsXdrops all the stashed states.gsllists stashed states.gsLlists dropped stashed states.gsddisplays changes between the stash and its original parent.gspremoves and applies a single stashed state from the stash list.gsrrecovers a given stashed state.gssstashes the changes of the dirty working directory, including untracked.gsSstashes the changes of the dirty working directory interactively.gswstashes the changes of the dirty working directory retaining the index.
Submodule
gSinitializes, updates, or inspects submodules.gSaadds given a repository as a submodule.gSfevaluates a shell command in each of checked out submodules.gSiinitializes submodules.gSIinitializes and clones submodules recursively.gSllists the commits of all submodules.gSmmoves a submodule.gSssynchronizes submodules' remote URL to the value specified in .gitmodules.gSufetches and merges the latest changes for all submodule.gSxremoves a submodule.
Working directory
gwsdisplays working-tree status in the short format.gwSdisplays working-tree status.gwddisplays changes between the working tree and the index (diff).gwDdisplays changes between the working tree and the index (word diff).gwrresets the current HEAD to the specified state, does not touch the index nor the working tree.gwRresets the current HEAD, index and working tree to the specified state.gwcremoves untracked files from the working tree (dry-run).gwCremoves untracked files from the working tree.gwxremoves files from the working tree and from the index recursively.gwXremoves files from the working tree and from the index recursively and forcefully.
Shadows
The following aliases may shadow system commands:
gptshadows the GUID partition table maintenance utility.gsshadows the Ghostscript.
If you frequently use the above commands, you may wish to remove said aliases
from this module or to disable them at the bottom of the zshrc with unalias.
You can temporarily bypass an alias by prefixing it with a backward slash:
\gpt.
Functions
git-branch-currentdisplays the current branch.git-commit-lostlists lost commits.git-dirdisplays the path to the Git directory.git-hub-browseopens the GitHub repository in the default browser.git-hub-shorten-urlshortens GitHub URLs.git-infoexposes repository information via the$git_infoassociative array.git-rootdisplays the path to the working tree root.git-stash-clear-interactiveasks for confirmation before clearing the stash.git-stash-droppedlists dropped stashed states.git-stash-recoverrecovers given dropped stashed states.git-submodule-movemoves a submodule.git-submodule-removeremoves a submodule.
Theming
To display information about the current repository in a prompt, define the
following styles in the prompt_name_setup function, where the syntax for
setting a style is as follows.
zstyle ':prezto:module:git:info:context:subcontext' format 'string'
Main Contexts
| Name | Format Code | Description |
|---|---|---|
| action | %s | Special action name |
| ahead | %A | Commits ahead of remote count |
| behind | %B | Commits behind of remote count |
| branch | %b | Branch name |
| commit | %c | Commit hash |
| position | %p | Commits from the nearest tag count |
| remote | %R | Remote name |
| stashed | %S | Stashed states count |
Concise Contexts
| Name | Format Code | Description |
|---|---|---|
| clean | %C | Clean state |
| dirty | %D | Dirty files count |
| indexed | %i | Indexed files count |
| unindexed | %I | Unindexed files count |
| untracked | %u | Untracked files count |
The following contexts must be enabled with the following zstyle:
zstyle ':prezto:module:git:info' verbose 'yes'
Verbose Contexts
| Name | Format Code | Description |
|---|---|---|
| added | %a | Added files count |
| clean | %C | Clean state |
| deleted | %d | Deleted files count |
| dirty | %D | Dirty files count |
| modified | %m | Modified files count |
| renamed | %r | Renamed files count |
| unmerged | %U | Unmerged files count |
| untracked | %u | Untracked files count |
Special Action Contexts
| Name | Format | Description |
|---|---|---|
| apply | value | Applying patches |
| bisect | value | Binary searching for changes |
| cherry-pick | value | Cherry picking |
| cherry-pick-sequence | value | Cherry picking sequence |
| merge | value | Merging |
| rebase | value | Rebasing |
| rebase-interactive | value | Rebasing interactively |
| rebase-merge | value | Rebasing merge |
First, format the repository state attributes. For example, to format the branch and remote names, define the following styles.
zstyle ':prezto:module:git:info:branch' format 'branch:%b'
zstyle ':prezto:module:git:info:remote' format 'remote:%R'
Second, format how the above attributes are displayed in prompts.
zstyle ':prezto:module:git:info:keys' format \
'prompt' ' git(%b)' \
'rprompt' '[%R]'
Last, add $git_info[prompt] to $PROMPT and $git_info[rprompt] to
$RPROMPT respectively and call git-info in the prompt_name_preexec hook
function.
Authors
The authors of this module should be contacted via the issue tracker.