Giter Club home page Giter Club logo

posh-git's Introduction

posh-git

Join the chat at https://gitter.im/dahlbyk/posh-git PowerShell Gallery posh-git on Chocolatey

Table of contents:

Overview

posh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that can be displayed in the PowerShell prompt, e.g.:

C:\Users\Keith\GitHub\posh-git [main ≡ +0 ~1 -0 | +0 ~1 -0 !]>

posh-git also provides tab completion support for common git commands, branch names, paths and more. For example, with posh-git, PowerShell can tab complete git commands like checkout by typing git ch and pressing the tab key. That will tab complete to git checkout and if you keep pressing tab, it will cycle through other command matches such as cherry and cherry-pick. You can also tab complete remote names and branch names e.g.: git pull or<tab> ma<tab> tab completes to git pull origin main.

Versions

posh-git v1.0

Windows (AppVeyor) Linux/macOS (Travis) Code Coverage Status
master build status master build status master build coverage

READMECHANGELOG

  • Supports Windows PowerShell 5.x
  • Supports PowerShell Core 6+ on all platforms
  • Supports ANSI escape sequences for color customization
  • Includes breaking changes from v0.x (roadmap)
    • All SSH commands removed from posh-git and moved into the new module posh-sshell

Releases

posh-git v0.x

Windows (AppVeyor) Code Coverage Status
v0 build status v0 build coverage

READMECHANGELOG

  • Supports Windows PowerShell 3+
  • Does not support PowerShell Core
  • Avoids breaking changes, maintaining v0.x

Releases

Installation

These installation instructions, as well as the rest of this README, applies only to version 1.x of posh-git. For v0.x installation instructions see this README.

Prerequisites

Before installing posh-git make sure the following prerequisites have been met.

  1. Windows PowerShell 5.x or PowerShell Core 6.0. You can get PowerShell Core 6.0 for Windows, Linux or macOS from here. Check your PowerShell version by executing $PSVersionTable.PSVersion.

  2. On Windows, script execution policy must be set to either RemoteSigned or Unrestricted. Check the script execution policy setting by executing Get-ExecutionPolicy. If the policy is not set to one of the two required values, run PowerShell as Administrator and execute Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm.

  3. Git must be installed and available via the PATH environment variable. Check that git is accessible from PowerShell by executing git --version from PowerShell. If git is not recognized as the name of a command, verify that you have Git installed. If not, install Git from https://git-scm.com. If you have Git installed, make sure the path to git is in your PATH environment variable.

Installing posh-git via PowerShellGet on Linux, macOS and Windows

posh-git is available on the PowerShell Gallery and can be installed using the built-in PowerShellGet module.

  1. Start Windows PowerShell 5.x or PowerShell >= v6 (pwsh).

  2. Execute one of the following two commands from an elevated PowerShell prompt, depending on whether (A) you've never installed posh-git, or (B) you've already installed a previous version:

    # (A) You've never installed posh-git from the PowerShell Gallery
    PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force

    NOTE: If you're asked to trust packages from the PowerShell Gallery, answer yes to continue installation of posh-git

    OR

    # (B) You've already installed a previous version of posh-git from the PowerShell Gallery
    PowerShellGet\Update-Module posh-git

Installing posh-git via Chocolatey

If you prefer to manage posh-git as a Windows package, you can use Chocolatey to install posh-git. If you don't have Chocolatey, you can install it from the Chocolatey Install page. With Chocolatey installed, execute the following command to install posh-git:

choco install poshgit

Installing posh-git via Scoop

Another popular package manager for Windows is Scoop, which you can also use to install posh-git. With Scoop installed, execute these commands to install posh-git and import it into your profile:

scoop bucket add extras
scoop install posh-git
Add-PoshGitToProfile

Installing posh-git Manually

If you need to test/debug changes prior to contributing here, or would otherwise prefer to install posh-git without the aid of a package manager, you can execute Import-Module <path-to-src\posh-git.psd1>. For example, if you have git cloned posh-git to ~\git\posh-git you can import this version of posh-git by executing Import-Module ~\git\posh-git\src\posh-git.psd1.

Using posh-git

After you have installed posh-git, you need to configure your PowerShell session to use the posh-git module.

Step 1: Import posh-git

The first step is to import the module into your PowerShell session which will enable git tab completion. You can do this with the command Import-Module posh-git.

Step 2: Import posh-git from your PowerShell profile

You do not want to have to manually execute the Import-Module command every time you open a new PowerShell prompt. Let's have PowerShell import this module for you in each new PowerShell session. We can do this by either executing the command Add-PoshGitToProfile or by editing your PowerShell profile script and adding the command Import-Module posh-git.

If you want posh-git to be available in all your PowerShell hosts (console, ISE, etc) then execute Add-PoshGitToProfile -AllHosts. This will add a line containing Import-Module posh-git to the file $profile.CurrentUserAllHosts.

If you want posh-git to be available in just the current host, then execute Add-PoshGitToProfile. This will add the same command but to the file $profile.CurrentUserCurrentHost.

If you want posh-git to be available for all users on the system, start PowerShell as Administrator or via sudo (sudo pwsh) on Linux/macOS then execute Add-PoshGitToProfile -AllUsers -AllHosts. This will add the import command to $profile.AllUsersAllHosts.

If you want to configure posh-git for all users but only for the current host, drop the -AllHosts parameter and the command will modify $profile.AllUsersCurrentHost.

If you'd prefer, you can manually edit the desired PowerShell profile script. Open (or create) your profile script with the command notepad $profile.CurrentUserAllHosts. In the profile script, add the following line:

Import-Module posh-git

Save the profile script, then close PowerShell and open a new PowerShell session. Type git fe and then press tab. If posh-git has been imported, that command should tab complete to git fetch.

If you want posh-git to detect your own aliases for git, then you must have set the alias before importing posh-git. So if you have Set-Alias g git then ensure it is executed before Import-Module posh-git, and g checkout will complete as if you'd typed git.

Git status summary information

The Git status summary information provides a wealth of "Git status" information at a glance, all the time in your prompt.

By default, the status summary has the following format:

[{HEAD-name} S +A ~B -C !D | +E ~F -G !H W]
  • [ (BeforeStatus)

  • {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
  • S represents the branch status in relation to the remote (tracked origin) branch.

    Note: This status information reflects the state of the remote tracked branch after the last git fetch/pull of the remote. Execute git fetch to update to the latest on the default remote repo. If you have multiple remotes, execute git fetch --all.

    • = The local branch is at the same commit level as the remote branch (BranchIdenticalStatus)
    • ↑<num> = The local branch is ahead of the remote branch by the specified number of commits; a git push is required to update the remote branch (BranchAheadStatus)
    • ↓<num> = The local branch is behind the remote branch by the specified number of commits; a git pull is required to update the local branch (BranchBehindStatus)
    • <a>↕<b> = The local branch is both ahead of the remote branch by the specified number of commits (a) and behind by the specified number of commits (b); a rebase of the local branch is required before pushing local changes to the remote branch (BranchBehindAndAheadStatus). NOTE: this status is only available if $GitPromptSettings.BranchBehindAndAheadDisplay is set to Compact.
    • × = The local branch is tracking a branch that is gone from the remote (BranchGoneStatus)
  • ABCD represent the index; | (DelimStatus); EFGH represent the working directory

    • + = Added files
    • ~ = Modified files
    • - = Removed files
    • ! = Conflicted files
    • As with git status output, index status is displayed in dark green and working directory status in dark red
  • W represents the overall status of the working directory

    • ! = There are unstaged changes in the working tree (LocalWorkingStatusSymbol)
    • ~ = There are uncommitted changes i.e. staged changes in the working tree waiting to be committed (LocalStagedStatusSymbol)
    • None = There are no unstaged or uncommitted changes to the working tree (LocalDefaultStatusSymbol)
  • ] (AfterStatus)

The symbols and surrounding text can be customized by the corresponding properties on $GitPromptSettings.

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

# On branch main
#
# 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

Customization variables

posh-git adds variables to your session to let you customize it, including $GitPromptSettings, $GitTabSettings, and $TortoiseGitSettings. For an example of how to configure your PowerShell profile script to import the posh-git module and create a custom prompt function that displays git status info, see the Customizing Your PowerShell Prompt section below.

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 ($GitPromptSettings.EnableFileStatus = $false), you can disable it on a repo-by-repo basis by adding individual repository paths to $GitPromptSettings.RepositoriesInWhichToDisableFileStatus.

Customizing the posh-git prompt

When you import the posh-git module, it will replace PowerShell's default prompt function with a new prompt function. The posh-git prompt function will display Git status summary information when the current directory is inside a Git repository. posh-git will not replace the prompt function if it has detected that you have your own, customized prompt function.

The prompt function provided by posh-git creates a prompt that looks like this:

~\GitHub\posh-git [main ≡]>

You can customize the posh-git prompt function or define your own custom prompt function. The rest of this section covers how to customize posh-git's prompt function using the global variable $GitPromptSettings.

If you'd like to make any of following changes permanent, i.e. available whenever you start PowerShell, put the corresponding setting(s) in one of your profile scripts after the line that imports posh-git.

For instance, you can customize the default prompt prefix to display a colored timestamp with these settings:

$GitPromptSettings.DefaultPromptPrefix.Text = '$(Get-Date -f "MM-dd HH:mm:ss") '
$GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColor]::Magenta

This will change the prompt to:

02-18 13:45:19 ~\GitHub\posh-git [main ≡]>

If you would prefer not to have any path under your home directory abbreviated with ~, use the following setting:

$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $false

This will change the prompt to:

C:\Users\Keith\GitHub\posh-git [main ≡]>

If you would like to change the color of the path, you can use the following setting on Windows:

$GitPromptSettings.DefaultPromptPath.ForegroundColor = 'Orange'

Note: Setting the ForegroundColor to a color name, other than one of the standard ConsoleColor names, only works on Windows. On Windows, posh-git uses the [System.Drawing.ColorTranslator]::FromHtml(string colorName) method to parse a color name as an HTML color. For a complete list of HTML colors, see this W3Schools page.

If you are on Linux or macOS and desire an Orange path, you will need to specify the RGB value for Orange e.g.:

$GitPromptSettings.DefaultPromptPath.ForegroundColor = 0xFFA500

This will change the prompt to:

~\GitHub\posh-git [main]>

If you would like to make your prompt span two lines, with a newline after the Git status summary, use this setting:

$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n'

This will change the prompt to:

~\GitHub\posh-git [main ≡]
>

You can swap the order of the path and the Git status summary with the following setting:

$GitPromptSettings.DefaultPromptWriteStatusFirst = $true

This will change the prompt to:

[main ≡] ~\GitHub\posh-git>

Finally, you can combine these settings to customize the posh-git prompt fairly significantly. In the DefaultPromptSuffix field below, we are prepending the PowerShell history id number before the prompt char > e.g.:

$GitPromptSettings.DefaultPromptWriteStatusFirst = $true
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n$([DateTime]::now.ToString("MM-dd HH:mm:ss"))'
$GitPromptSettings.DefaultPromptBeforeSuffix.ForegroundColor = 0x808080
$GitPromptSettings.DefaultPromptSuffix = ' $((Get-History -Count 1).id + 1)$(">" * ($nestedPromptLevel + 1)) '

This will change the prompt to:

[main ≡] ~\GitHub\posh-git
02-18 14:04:35 38>

Finally, the path portion of the prompt can be contained within delimiters. For instance, if you would like the containing characters to be red, curly braces, the following settings can be used:

$GitPromptSettings.BeforePath = '{'
$GitPromptSettings.AfterPath = '}'
$GitPromptSettings.BeforePath.ForegroundColor = 'Red'
$GitPromptSettings.AfterPath.ForegroundColor = 'Red'

With these additional values, the previous prompt would become

[main ≡] {~\GitHub\posh-git}
02-18 14:04:35 38>

Prompt Layouts

For reference, the following layouts show the relative position of the various parts of the posh-git prompt. Note that <> denotes parts of the prompt that may not appear depending on the status of settings and whether or not the current dir is in a Git repository. To simplify the layout, DP is being used as an abbreviation for DefaultPrompt settings.

Default prompt layout:

{DPPrefix}{BeforePath}{DPPath}{AfterPath}{PathStatusSeparator}<{BeforeStatus}{Status}{AfterStatus}>{DPBeforeSuffix}<{DPDebug}><{DPTimingFormat}>{DPSuffix}

Prompt layout when DefaultPromptWriteStatusFirst is set to $true:

{DPPrefix}<{BeforeStatus}{Status}{AfterStatus}>{PathStatusSeparator}{BeforePath}{DPPath}{AfterPath}{DPBeforeSuffix}<{DPDebug}><{DPTimingFormat}>{DPSuffix}

Displaying Error Information

If you want to display the error status of the last command, you can use the values stored in the $global:GitPromptValues object which includes the value of $LastExitCode and $? (represented by the property DollarQuestion). Here is a prompt customization that displays a Red exit code value when $LastExitCode is non-zero or a Red ! if $? is $false:

function global:PromptWriteErrorInfo() {
    if ($global:GitPromptValues.DollarQuestion) { return }

    if ($global:GitPromptValues.LastExitCode) {
        "`e[31m(" + $global:GitPromptValues.LastExitCode + ") `e[0m"
    }
    else {
        "`e[31m! `e[0m"
    }
}

$global:GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n$(PromptWriteErrorInfo)$([DateTime]::now.ToString("MM-dd HH:mm:ss"))'

When a PowerShell command fails, this is the prompt you will see:

~\GitHub\posh-git [main ≡]
! 07-01 22:36:31>

When an external application returns a non-zero exit code, 1 in this case, you will see the exit code in the prompt:

~\GitHub\posh-git [main ≡]
(1) 07-01 22:32:28>

Note that until you run an external application that sets $LASTEXITCODE to zero or you manually set the variable to 0, you will see the exit code for any error. In addition to LastExitCode and DollarQuestion, $global:GitPromptValues also has IsAdmin and LastPrompt properties. The LastPrompt property contains the ANSI escaped string that was used for the last prompt. This can be useful for debugging your prompt display particularly when using ANSI/VT sequences.

$GitPromptScriptBlock

If you require even more customization than $GitPromptSettings provides, you can create your own prompt function to show whatever information you want. See the Customizing Your PowerShell Prompt wiki page for details.

However, if you need a custom prompt just to perform some non-prompt logic, you can still use posh-git's prompt function to write out the prompt string. This can be done with the $GitPromptScriptBlock variable as shown below e.g.:

# my profile.ps1
function prompt {
    # Your non-prompt logic here

    # Have posh-git display its default prompt
    & $GitPromptScriptBlock
}

And if you'd like to write prompt text before and/or after the posh-git prompt, you can use posh-git's Write-Prompt command as shown below:

# my profile.ps1
function prompt {
    # Your non-prompt logic here
    $prompt = Write-Prompt "Text before posh-git prompt " -ForegroundColor ([ConsoleColor]::Green)
    $prompt += & $GitPromptScriptBlock
    $prompt += Write-Prompt "Text after posh-git prompt" -ForegroundColor ([ConsoleColor]::Magenta)
    if ($prompt) { "$prompt " } else { " " }
}

Based on work by

posh-git's People

Contributors

alanstevens avatar bergmeister avatar breisfeld avatar cmarcusreid avatar coridrew avatar csc027 avatar dahlbyk avatar dannoe avatar dscho avatar eamodio avatar exe-boss avatar ferventcoder avatar haroldalmon avatar jeremyskinner avatar lukebakken avatar lzybkr avatar markembling avatar mikesigs avatar paulmarsy avatar ra0to avatar rdnlsmith avatar rkeithhill avatar rkeithhill-keysight avatar seamlessintegrations avatar skeept avatar theaquamarine avatar thesned avatar tomone avatar viceice avatar vorou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

posh-git's Issues

Get-SshAgent() doesn't work

Here is my profile:

$agent = Get-SshAgent
if ($agent -eq 0) {
    Write-Host "Starting SSH agent..."
    Start-SshAgent -Quiet       # Start agent
    Add-SshKey          # Add my default key
} else {
    Write-Host "SSH agent is running (PID $agent)"
}

When this is run PS errors with

Get-SshAgent : The term 'Get-SshAgent' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Projects\Test\posh-git\profile.example.ps1:36 char:10

  • $agent = Get-SshAgent
  •      ~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (Get-SshAgent:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

I've modified the profile just to call Get-SshAgent on its own and the same error appears.

Repo Status in Submodule

Currently we show "(unknown)" when the current directory is within a submodule. Should display part of the submodule SHA instead (like bash).

Can haz websight?

http://dahlbyk.github.com/posh-git/

This here project has long since outgrown a readme. Stuff that needs to be documented:

  • What the prompt means (readme may be good enough)
  • Why the prompt might be slow (sigh) and workarounds
  • $GitPromptSettings Colors/Delimiters
  • $GitPromptSettings Behaviors: Debug, EnableFileStatus, RepositoriesInWhichToDisableFileStatus, etc
  • Supported tab expansions
  • $GitTabSettings
  • ssh-agent Helpers
  • Update-AllBranches

What else?

Startup time is too long in Git Shell

Hi,

I've install GitHub for Windows(1.0.38.1) in 3 PCs and all set PowerShell as it's default Shell. But when I click "Git Shell" icon to open the shell console, my fast PC(core-i7) take the longest startup time(more than 12 secs), others slow PC just take about 2-3 secs. Could advise how to find the root cause of this issue?

Have PsGet install Posh-Git as a Git repository

I used PsGet (http://psget.net/) to install Posh-Git on my machine. It was lovely and easy! But now I noticed that my version of Posh-Git is out of date. :(

Ideally, PsGet would be updated frequently. But perhaps even better, have the PsGet package include the posh-git repository so that it's easy to update. :)

Posh-git is too slow

I installed GitHub for Windows, which include posh-git. When I use the included GitHub Powershell link, it loads posh-git.

Just loading the posh-git part in a new Powershell window is very slow, taking 8 seconds. Pressing the "enter" key on an empty line takes 3 seconds to show a new prompt.

Here's a video (needs Flash, no audio):
https://www.Scolab.com/Public/Jing/VideoPlayer/Jing.aspx?filename=../CM/slowposhgit2012-06-01_1507.mp4&width=1224&height=672

The machine is quite fast (Intel i7 laptop, dual-core with SSD hard disk). The project weight 726 MB and has 2500 folders and 16300 files, excluding the ".git" folder.

I can live with the slow loading, but not with the wait. Could it disable itself or limit itself if it detects that it's taking more than 500ms to show?

Thanks a lot,
Carl

Index status vs working directory status colours

From the readme: "As in git status, index status is dark red and working directory status is dark green".

Isn't it the other way round? I've started to use posh-git for the first time, and have got confused by the index status colour vs the working directory status colour. Seems to me that index is green and w-d is red.

posh-git does not generate the informational prompt on Win8 Release Preview

On Win8 Consumer Preview, posh-git embedded the git status information into the PowerShell prompt without a problem. On the latest build of Win8 Release Preview, I am no longer able to get the rich prompt. (Also looks like tab completion etc are broken.)

I also updated to the latest version of msysgit at the same time I updated to the latest Win8 drop, so I guess it could be a change there as well.

Very Slow prompt return

It takes several seconds for the branch and change stuff to show up.
Is this a core thing in posh-git.

I'd love to understand more about the implementation of how the information is gathered from the repo.

Looks for .ssh folder in wrong location?

(I'm posting this here, because GitHub said I should - I encountered this issue when launching the console from the GitHub for Windows app)

I (used to) use MsysGit, which looks in %HOME% for the .ssh folder. posh-git looks in %HOMEPATH%. This leads to two different .ssh folders.

Could posh-git be changed, so it looks for the .ssh-folder in %HOME% if this variable is present and falls back to %HOMEPATH% if it isn't? That way the transition from MsysGit to posh-git (or the use of both) would be a lot easier.

Remove remote merged branches command

So we (GHfW) team have a PowerShell script that will list all remote branches that are already merged into a specified branch (it defaults to origin/master if no branch is supplied) and offer to delete them for you.

I'd love to clean it up and add it as a command to GitUtils.ps1. Would you be interested in such a thing as part of Posh-Git?

posh git + pscx = broken shell

There seems to be some sort of compatibility problem between posh git and PSCX. Loading both modules at once causes incorrect format for 'help' command output (all lines end with <- [m), tab completion for parameter names on many cmdlets no longer works, and tab completion becomes really slow.

"flashplayerplugin" Displaying at prompt

I'm getting some very strange behavior on my machine that I'm worried might be due to malware, but I want to eliminate post-git as a possible source first.

Do you guys have any idea where the string "flashplayerplugin" could be injected as to cause this error? It only happens in directories that are git repos. I'm running a full system check now, but wanted to get this in a public space just in case posh-git itself was the cause.

flashplayerpluginWindows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

Cannot index into a null array.
At C:\Users\jkodroff\Code\posh-git\CheckVersion.ps1:11 char:34
+     $version = [Version]$Matches[ <<<< 'ver']
    + CategoryInfo          : InvalidOperation: (ver:String) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

WARNING: posh-git requires Git 1.7.2 or better. You have .
C:\Users\jkodroff\Code\rms [flashplayerplugincod-only flashplayerplugin +4 ~6 -1 !]>

"git rm filename" gives error "Deletion of directory 'parentfolder' failed"

This is using the posh-git included in github for windows.

C:\dev\TeamHaven\cdsweb\Images [master]> git rm leftarrow.gif
rm 'cdsweb/Images/leftarrow.gif'
Deletion of directory 'cdsweb/Images' failed. Should I try again? (y/n) n

The file is marked for deletion though, but obviously if this isn't a spurious message, it's a bit concerning that it's trying to delete the folder too!

Better README

The introduction/README on the site should include a description of what the colors/text in the command prompt mean. A beginner's guide. This doesn't have to be long, but SOMETHING on the site explaining the project would be nice.

Distinguish git-svn repos

I'll often jump into a git repo and forget whether it's pushing to other git repositories or an svn repo. It throws me off for a few seconds when I see 'origin is not a repository'.

It would be nice if git-svn repositories had some type of distinguisher. Maybe [svn:master] or different color set.

Tab completion does not work if PowerTab module is loaded

C:\Users\aaronlev\chrome\chrome0\src [tab_states]> import-module PowerTab
PowerTab version 0.99.6.0 PowerShell TabExpansion Library
Host: ConsoleHost
PowerTab Enabled: True
C:\Users\aaronlev\chrome\chrome0\src [tab_states]> git branch ## Shows popup with list of files for autocomplete

C:\Users\aaronlev\chrome\chrome0\src [tab_states]> remove-module PowerTab
C:\Users\aaronlev\chrome\chrome0\src [tab_states]> git branch ## Cycles through branches

If there's a configuration option I'm missing, it wasn't clear to me -- search engines couldn't find me the answer either.

prompt color updating incorrectly? (with my current workflow)

This maybe more of an issue w/ my git workflow so please help me if I'm doing this all wrong...

Setup:

  • Colors - "Blue" (It's not blue, but it's sort of blue and i'll refer to it as a blue color going forward). This is the color that shows after I've done a git push origin master and everything is in sync.
    "Red" - the color when I've committed local changes, but have not pushed those up to remote.

My issue is when my state is Blue and I run "git pull origin master" I would expect my color to stay blue. However it turns red, it's not until I then run "git remote update" that it turns blue.

Is there a better workflow for me? Or any other thoughts on this?

Disable color of git status

Color should be explicitly disabled on "git status" call at GitUtils.ps1:104.

old: git status --short --branch
new: git -c color.status=false status --short --branch

viceice@f034c69

Regards

Broken stash apply

When using posh-git and trying to apply my stash, the following command
git stash apply --index 0 or git stash apply stash@{0}

Both give the error:
fatal: ambiguous argument '0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

Using the default Git bash works. What am I doing wrong?

possible issue with 1.7.7.1 msysgit

tried installing msysgit 1.7.7.1 and git stopped working. not sure if this is a posh-git thing or a git thing. but should probably be looked at.

Auto-Update Upon Opening Powershell (optional)

Add a parameter and functionality so the user has the option to enable "auto-update" functionality whereby upon opening Powershell, a git pull request will trigger causing the user's posh-git scripts to be updated to the latest version.

Completion of submodule subcommands does not work

When I type git sub<TAB>, the completion works as expected: the fragment is expanded to git submodule. When I type git sub<TAB> up<TAB>, the completion does not work.

I've also noticed that git ls-f<TAB> is also not completed as expected (git ls-files).

SQL Server Snapin

Changing into SQLSERVER:\sql yields an error:

The term 'w' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Error when installing posh git

For some unexpected reasons module was not installed.
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:823 char:18
+             throw <<<<  "For some unexpected reasons module was not installed."
    + CategoryInfo          : OperationStopped: (For some unexpe... not installed.:String) [], RuntimeException
    + FullyQualifiedErrorId : For some unexpected reasons module was not installed.

Exception calling "GetDirectoryName" with "1" argument(s): "The path is not of a legal form."
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:171 char:67
+         $TempModuleFolderPath = [System.IO.Path]::GetDirectoryName <<<< ($ModulePath)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression.
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:629 char:47
+     $destination.Copyhere($PSGET_ZIPFile.items <<<< ())
    + CategoryInfo          : InvalidOperation: (items:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:624 char:29
+     if ($PSGET_ZIPFile.items <<<< () | Where-Object { $_.Path -eq $ContentTypesXmlPath }) {
    + CategoryInfo          : InvalidOperation: (items:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\PsGet\PsGet.psm1:623 char:43
+     $ContentTypesXmlPath = Join-Path -Path <<<<  $PSGET_ZIPFile.Self.Path -ChildPath '[Content_Types].xml'
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand

Issue with tab expansion and non-English file names

Repro steps:

  1. touch 慣用音.txt
  2. git add {tab}

Expected: it expands the filename.
Actual: it expands to:

git add "\346\205\243\347\224\250\351\237\263.txt"

That wouldn't be a problem except it doesn't work.

  1. git config core.quotepath true
  2. git add {tab}

Result:

Install in 'Program Files' dir fails

I installed posh-git to c:\Program Files\posh-git and when i restarted powershell this is what I got...

The term 'C:\Program' is not recognized as the name of a
spelling of the name, or if a path was included, verify t
At C:\Users\xxxx\Documents\WindowsPowerShell\

  • . <<<< C:\Program Files\posh-git\profile.example.ps1
    • CategoryInfo : ObjectNotFound: (C:\Program
    • FullyQualifiedErrorId : CommandNotFoundException

Add a Stop-SshAgent cmdlet

Posh-Git includes a Start-SshAgent cmdlet, but no corresponding Stop-SshAgent command.

Why would I need one? Well occasionally it seems SSH Agent gets in a state where it's running, but it's not supplying my credentials. So I end up having to supply my pass phrase.

I end up wanting to restart the agent, but I have to go into task manager and kill the process and then run the Start-SshAgent command.

I'd prefer to be able to run Stop-SshAgent and then start it again. Or perhaps even have a Restart-SshAgent command. :)

git rm tab completion issues

Running the command git rm no longer tabs through files to be deleted

For instance
deleted /FolderA/fileA
deleted /FolderA/fileB
deleted /FolderB/fileA

git rm used to give
git rm /FolderA/fileA --first tab
git rm /FolderA/fileB --secondtab

now it gives
git rm ./FolderA -- first tab
git rm ./FolderB -- second tab

Update default color scheme

Dark red color is barely visible on the dark blue background of the PowerShell window :(

C:\Projects\SiteSDK [master +0 ~1 -0]>

$lastexitcode lost

This is not really a posh-git issue, but more general to overriding the prompt function in powershell. Have you notice that running your custom prompt will clear $lastexitcode?

Create a script named "fail.ps1" that simple calls "exit 123". Run it and you'll see $? is false while $lastexitcode is 0. $lastexitcode should be 123. Run powershell without running your profile first, then run fail.ps1, and indeed $lastexitcode is 123.

I also posted this on SO, but thought you may be interested. Maybe you have some ideas?

http://stackoverflow.com/questions/6014042/custom-powershell-prompt-is-clearing-lastexitcode

Calls to git fail when in a UNC-specified directory

If I cd into the location of a git repo via UNC (like //server/share/dir/subdir) then any git commands fail like so:

Microsoft.PowerShell.Core\FileSystem::\\groups\data\ctrhs\crn\ccrc\oncologynurse\programming\programs [(master)]> git status
'\\groups\data\ctrhs\crn\ccrc\oncologynurse\programming\programs'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
fatal: Not a git repository (or any of the parent directories): .git

Does that indicate bad config on my end? If so, how can I fix? If not--is it something you can fix? The msysgit bash command prompt doesn't have this problem.

Many thanks!

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.