|
| 1 | +# ugit |
| 2 | +Updated Git: A powerful PowerShell wrapper for git that lets you extend git, automate multiple repos, and output git as objects. |
| 3 | + |
| 4 | + |
| 5 | +## What is ugit? |
| 6 | + |
| 7 | +ugit is a PowerShell module that gives you an updated git. You can use the object pipeline to pipe folders or files into git. |
| 8 | +If you're using one of a number of supported commands, ugit will return your git output as objects. |
| 9 | +This enables _a lot_ of interesting scenarios, giving you and updated way to work with git. |
| 10 | + |
| 11 | +## Getting started |
| 12 | + |
| 13 | +### Installing ugit |
| 14 | +~~~PowerShell |
| 15 | +Install-Module ugit -Scope CurrentUser |
| 16 | +Import-Module ugit -Force -PassThru |
| 17 | +# Once you've imported ugit, just run git commands normally. |
| 18 | +# If ugit has an extension for the command, it will output as an object. |
| 19 | +# These objects can be formatted by PowerShell |
| 20 | +git log -n 5 |
| 21 | +
|
| 22 | +# To get a sense of what you can do, pipe a given git command into Get-Member. |
| 23 | +git log -n 5 | |
| 24 | + Get-Member |
| 25 | +~~~ |
| 26 | + |
| 27 | + |
| 28 | +## How ugit works: |
| 29 | + |
| 30 | +ugit only has a few commands: |
| 31 | + |
| 32 | +### Use-Git |
| 33 | + |
| 34 | +After you've imported ugit, Use-Git is what will be called when you run "git". |
| 35 | + |
| 36 | +This happens because Use-Git is aliased to "git", and aliases are resolved first in PowerShell. |
| 37 | + |
| 38 | +Use-Git assumes all positional parameters are arguments to Git, and passes them on directly. |
| 39 | + |
| 40 | +This works in almost every scenario, except with some single character git options. You can pass these in quotes. |
| 41 | + |
| 42 | +When Use-Git outputs, it sets $global:LastGitOutput and then pipes to Out-Git. |
| 43 | + |
| 44 | +### Out-Git |
| 45 | + |
| 46 | +Out-Git will attempt to take git output and return it as a useful object. |
| 47 | + |
| 48 | +This object can then be extended and formatted by PowerShell's Extended Type System. |
| 49 | + |
| 50 | +Out-Git accomplishes this with several extensions. You can list extensions with Get-UGitExtension: |
| 51 | + |
| 52 | +### Get-UGitExtension |
| 53 | + |
| 54 | +Get-UGitExtension enables any file beneath ugit (or a module that tags ugit) named *.ugit.extension.ps1 to be treated as an extension. |
| 55 | + |
| 56 | +In ugit, extensions signal that they apply to a given git command by adding a ```[ValidatePattern]``` attribute to the command. |
| 57 | + |
| 58 | +If this pattern matches the given git command, the extension will run. |
| 59 | + |
| 60 | +Get-UGitExtension is built using [Piecemeal](https://github.com/StartAutomating/Piecemeal) |
| 61 | + |
| 62 | +## Git Commands Extended |
| 63 | + |
| 64 | +* git branch |
| 65 | +* git commit |
| 66 | +* git clone |
| 67 | +* git diff |
| 68 | +* git log |
| 69 | +* git push |
| 70 | +* git status |
| 71 | + |
| 72 | + |
| 73 | +### Extensions that may apply to any git command: |
| 74 | + |
| 75 | +* git.fileoutput |
| 76 | + |
| 77 | +This applies to an git command that uses the -o flag. |
| 78 | +It will attempt to locate any output specified by -o and return it as a file or directory. |
0 commit comments