diff --git a/modules/git/README.md b/modules/git/README.md index bc08b33..364ef28 100644 --- a/modules/git/README.md +++ b/modules/git/README.md @@ -3,10 +3,8 @@ Git Provides nice git aliases and functions. -Also provides functions necessary for many prompts. - -Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for the excellent aliases. - +Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for the +excellent aliases. Aliases ------- @@ -21,23 +19,22 @@ Aliases - `gbc` creates a new branch. - `gbl` lists branches and their commits. - `gbL` lists local and remote branches and their commits. + - `gbm` renames a branch. + - `gbM` renames a branch even if the new branch name already exists. - `gbs` lists branches and their commits with ancestry graphs. - `gbS` lists local and remote branches and their commits with ancestry graphs. - `gbx` deletes a branch. - `gbX` deletes a branch irrespective of its merged status. - - `gbm` renames a branch. - - `gbM` renames a branch even if the new branch name already exists. - ### Commit - `gc` records changes to the repository. - - `gca` stages all modified and deleted files. - - `gcm` records changes to the repository with the given message. - - `gco` checks out a branch or paths to work tree. + - `gca` commits all modified and deleted files. + - `gcm` commits with the given message. + - `gco` checks out a branch or paths to the working tree. - `gcO` checks out hunks from the index or the tree interactively. - - `gcf` amends the tip of the current branch using the same log message as + - `gcf` amends the tip of the current branch reusing the same log message as *HEAD*. - `gcF` amends the tip of the current branch. - `gcp` applies changes introduced by existing commits. @@ -45,14 +42,15 @@ Aliases - `gcr` reverts existing commits by reverting patches and recording new commits. - `gcR` removes the *HEAD* commit. - - `gcs` displays various types of objects. + - `gcs` shows one or more objects (blobs, trees, tags and commits). - `gcl` lists lost commits. + - `gcS` commits with GPG signature. ### Conflict - `gCl` lists unmerged files. - `gCa` adds unmerged file contents to the index. - - `gCe` executes merge-tool on all unmerged file. + - `gCe` executes merge-tool on all unmerged files. - `gCo` checks out our changes for unmerged paths. - `gCO` checks out our changes for all unmerged paths. - `gCt` checks out their changes for unmerged paths. @@ -91,7 +89,7 @@ Aliases - `giu` adds file contents to the index (updates only known files). - `gid` displays changes between the index and a named commit (diff). - `giD` displays changes between the index and a named commit (word diff). - - `gir` resets the current HEAD to the specified state. + - `gir` resets the current *HEAD* to the specified state. - `giR` resets the current index interactively. - `gix` removes files/directories from the index (recursively). - `giX` removes files/directories from the index (recursively and forced). @@ -106,26 +104,27 @@ Aliases - `glG` displays the graph log with authors and dates. - `glb` displays the brief commit log. - `glc` displays the commit count for each contributor in descending order. + - `glS` displays the log verifying the GPG signature of commits. ### Merge - `gm` joins two or more development histories together. - - `gmC` joins two or more development histories together but does not commit. - - `gmF` joins two or more development histories together but does not commit - generating a merge commit even if the merge resolved as a fast-forward. + - `gmC` performs the merge but does not commit. + - `gmF` performs the merge generating a commit even if the merge resolved as a + fast-forward. - `gma` aborts the conflict resolution, and reconstructs the pre-merge state. - `gmt` runs the merge conflict resolution tools to resolve conflicts. ### Push - `gp` updates remote refs along with associated objects. - - `gpf` forcefully updates remote refs along with associated objects. - - `gpa` updates remote branches along with associated objects. - - `gpA` updates remote branches and tags along with associated objects. - - `gpt` updates remote tags along with associated objects. - - `gpc` updates remote refs along with associated objects and adds *origin* - as an upstream reference for the current branch. - - `gpp` pulls and pushes from origin to origin. + - `gpf` forces a push. + - `gpa` pushes all branches. + - `gpA` pushes all branches and tags. + - `gpt` pushes all tags. + - `gpc` pushes the current branch and adds *origin* as an upstream reference + for it. + - `gpp` pulls and pushes the current branch from *origin* to *origin*. ### Rebase @@ -144,8 +143,7 @@ Aliases - `gRm` renames a remote. - `gRu` fetches remotes updates. - `gRp` prunes all stale remote tracking branches. - - `gRs` displays information about a given remote. - - `gRb` opens a remote on GitHub in the default browser. + - `gRs` shows information about a given remote. ### Stash @@ -158,9 +156,9 @@ Aliases - `gsd` displays changes between the stash and its original parent. - `gsp` removes and applies a single stashed state from the stash list. - `gsr` recovers a given stashed state. - - `gss` stashes the changes of the dirty working directory, including untracked. - - `gsS` stashes the changes of the dirty working directory interactively. - - `gsw` stashes the changes of the dirty working directory retaining the index. + - `gss` stashes the working directory changes, including untracked files. + - `gsS` stashes the working directory changes interactively. + - `gsw` stashes the working directory changes retaining the index. - `gsu` unapplies (reverts) applied changes. ### Submodule @@ -174,24 +172,36 @@ Aliases - `gSm` moves a submodule. - `gSs` synchronizes submodules' remote URL to the value specified in .gitmodules. - - `gSu` fetches and merges the latest changes for all submodule. + - `gSu` fetches and merges the latest changes for all submodules. - `gSx` removes a submodule. -### Working directory +### Tag + + - `gt` creates, lists, deletes or verifies a tag object signed with GPG. + - `gts` creates a GPG-signed tag. + - `gtv` verifies the GPG signature of tags. + - `gtx` deletes tags with given names. + +### Working tree - `gws` displays working-tree status in the short format. - `gwS` displays working-tree status. - `gwd` displays changes between the working tree and the index (diff). - `gwD` displays changes between the working tree and the index (word diff). - - `gwr` resets the current HEAD to the specified state, does not touch the - index nor the working tree. - - `gwR` resets the current HEAD, index and working tree to the specified state. - - `gwc` removes untracked files from the working tree (dry-run). - - `gwC` removes untracked files from the working tree. + - `gwr` resets the current *HEAD* to the specified state, does not touch the + index nor the working tree. + - `gwR` resets the current *HEAD*, index and working tree to the specified + state. + - `gwc` cleans untracked files from the working tree (dry-run). + - `gwC` cleans untracked files from the working tree. - `gwx` removes files from the working tree and from the index recursively. - `gwX` removes files from the working tree and from the index recursively and forcefully. +### Misc + + - `g..` changes the current directory to the top level of the working tree. + ### Shadows The following aliases may shadow system commands: diff --git a/modules/git/init.zsh b/modules/git/init.zsh index 113d0c8..1400fdd 100644 --- a/modules/git/init.zsh +++ b/modules/git/init.zsh @@ -44,13 +44,13 @@ alias gcp='git cherry-pick --ff' alias gcP='git cherry-pick --no-commit' alias gcr='git revert' alias gcR='git reset "HEAD^"' -alias gcs='git show' +alias gcs='git show --pretty=format:"${_git_log_medium_format}"' alias gcl='git-commit-lost' alias gcS='git commit -S' alias gpS='git show --pretty=short --show-signature' # Conflict (C) -alias gCl='git status | sed -n "s/^.*both [a-z]*ed: *//p"' +alias gCl='git diff --diff-filter=U --name-only --no-pager' alias gCa='git add $(gCl)' alias gCe='git mergetool $(gCl)' alias gCo='git checkout --ours --' @@ -90,19 +90,19 @@ alias gid='git diff --no-ext-diff --cached' alias giD='git diff --no-ext-diff --cached --word-diff' alias gir='git reset' alias giR='git reset --patch' -alias gix='git rm -r --cached' -alias giX='git rm -r --cached --force' +alias gix='git rm --cached -r' +alias giX='git rm --cached -rf' # Log (l) alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"' alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"' alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"' alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"' -alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"' -alias glG='git log --topo-order --all --graph --pretty=format:"${_git_log_fullgraph_format}" --date=relative' +alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}%n"' +alias glG='git log --topo-order --all --graph --pretty=format:"${_git_log_fullgraph_format}"' alias glb='git log --topo-order --pretty=format:"${_git_log_brief_format}"' alias glc='git shortlog --summary --numbered' -alias glS='git log --show-signature' +alias glS='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"' # Merge (m) alias gm='git merge' @@ -165,10 +165,12 @@ alias gSu='git submodule foreach git pull origin master' alias gSx='git-submodule-remove' # Tag (t) +alias gt='git tag' alias gts='git tag --sign' alias gtv='git verify-tag' +alias gtx='git tag --delete' -# Working Copy (w) +# Working tree (w) alias gws='git status --short' alias gwS='git status' alias gwd='git diff --no-ext-diff' @@ -178,7 +180,7 @@ alias gwR='git reset --hard' alias gwc='git clean --dry-run' alias gwC='git clean -d --force' alias gwx='git rm -r' -alias gwX='git rm -r --force' +alias gwX='git rm -rf' # Misc alias g..='cd "$(git-root || print .)"'