Coder Social home page Coder Social logo

posh-git's Introduction

posh-git

A set of PowerShell scripts which provide Git/PowerShell integration

Prompt for Git repositories

The prompt within Git repositories can show the current branch and the state of files (additions, modifications, deletions) within.

Tab completion

Provides tab completion for common commands when using git.
E.g. git ch<tab> --> git checkout

Usage

See profile.example.ps1 as to how you can integrate the tab completion and/or git prompt into your own profile. Prompt formatting, among other things, can be customized using $GitPromptSettings, $GitTabSettings and $TortoiseGitSettings.

Note on performance: displaying file status in the git prompt for a very large repo can be prohibitively slow. Rather than turn off file status entirely, you can disable it on a repo-by-repo basis by adding individual repository paths to $GitPromptSettings.RepositoriesInWhichToDisableFileStatus.

Installing

  1. Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion

  2. Verify execution of scripts is allowed with Get-ExecutionPolicy (should be RemoteSigned or Unrestricted). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm.

  3. Verify that git can be run from PowerShell. If the command is not found, you will need to add a git alias or add %ProgramFiles%\Git\cmd to your PATH environment variable.

  4. Clone the posh-git repository to your local machine.

  5. From the posh-git repository directory, run .\install.ps1.

  6. Enjoy!

The Prompt

PowerShell generates its prompt by executing a prompt function, if one exists. posh-git defines such a function in profile.example.ps1 that outputs the current working directory followed by an abbreviated git status:

C:\Users\Keith [master]>

By default, the status summary has the following format:

[{HEAD-name} +A ~B -C !D | +E ~F -G !H]
  • {HEAD-name} is the current branch, or the SHA of a detached HEAD
  • Cyan means the branch matches its remote
  • Green means the branch is ahead of its remote (green light to push)
  • Red means the branch is behind its remote
  • Yellow means the branch is both ahead of and behind its remote
  • ABCD represent the index; EFGH represent the working directory
  • + = Added files
  • ~ = Modified files
  • - = Removed files
  • ! = Conflicted files
  • As in git status, index status is dark green and working directory status is dark red

For example, a status of [master +0 ~2 -1 | +1 ~1 -0] corresponds to the following git status:

# On branch master
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#        modified:   this-changed.txt
#        modified:   this-too.txt
#        deleted:    gone.ps1
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#        modified:   not-staged.ps1
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#        new.file

Based on work by:

posh-git's People

Contributors

dahlbyk avatar markembling avatar jeremyskinner avatar lukebakken avatar eamodio avatar deralbertcom avatar chrismissal avatar rodpl avatar tigraine avatar saintgimp avatar viceice avatar fschwiet avatar dwoof42 avatar weeble avatar tgmayfield avatar haacked avatar markborcherding avatar jbuedel avatar gliptak avatar drmohundro avatar bradleylandis avatar aroben avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.