New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Checkout from Powershell ISE displayes error message but works fine. #109

Closed
robianmcd opened this Issue Jul 25, 2013 · 7 comments

Comments

Projects
None yet
5 participants
@robianmcd
Copy link

robianmcd commented Jul 25, 2013

When I checkout a branch from Powershell ISE I get an error message like this:

git : Switched to branch 'newBranch'
At line:1 char:1

  • git checkout newBranch
  • - CategoryInfo          : NotSpecified: (Switched to branch 'newBranch':String) [], RemoteException
    - FullyQualifiedErrorId : NativeCommandError
    
    

If I checkout from powershell console I don't get the message. The answer for this question http://stackoverflow.com/questions/2095088/error-when-calling-3rd-party-executable-from-powershell-when-using-an-ide explains how Powershell Console and Powershell ISE handle standard error differently but I don't understand why anything is getting sent to standard error when you checkout.

Any idea what's going on here?
Thanks,
Rob

@wekempf

This comment has been minimized.

Copy link

wekempf commented Jul 25, 2013

This is git being stupid, I'm afraid. Many git commands send output to stderr that, quite frankly, should be sent to stdout instead. Checkout is one such command. In the console (not ISE) try this:

PS> git checkout branch1
Switched to branch 'branch1'
PS> git checkout master
Switched to branch 'master'
PS> git checkout branch1 2>&1
git : Switched to branch 'branch1'
At line:1 char:1

  • git checkout branch1 2>&1
  • - CategoryInfo             : NotSpecified: (Switched to branch 'branch1':String) [], RemoteException
    - FullyQualifiedErrorId : NativeCommandError
    
    

I really don't like how PowerShell handles stderr, but TRWTF is git sending this information to stderr.

@robianmcd

This comment has been minimized.

Copy link

robianmcd commented Jul 25, 2013

Ah that's annoying. Thanks for the info though. Any known workarounds other than just sending stderr to $null?

@dahlbyk

This comment has been minimized.

Copy link
Owner

dahlbyk commented Jul 26, 2013

Not that I know of. Closing since this is not really something I think we can fix, but feel free to continue discussion.

@wekempf

This comment has been minimized.

Copy link

wekempf commented Jul 26, 2013

Some unsatisfactory workarounds:

git checkout branch 2>&1 | % { $_.ToString() } # I've read this can get some lines out of order, but I don't know why.
(cmd /c git checkout branch 2>&1) # Sure to work, but less efficient and a pita. OK for scripts, I guess.

This is one really good argument for the PowerShell wrappers that are being discussed.

@robianmcd

This comment has been minimized.

Copy link

robianmcd commented Jul 26, 2013

@wekempf thanks, I couldn't figure out how to get rid of all that extra "at line:1..." stuff. But yeah, the best solution for now may be to just get used to the error being there.

@robianmcd robianmcd closed this Jul 26, 2013

@giggio

This comment has been minimized.

Copy link

giggio commented Jan 4, 2015

I know this is an old one, but just in case anyone reads this after me: you can use -q option to stop progress reporting, like this: git clone -q <otherparams>. This will remove all the unnecessary info powershell would show.

brechtm added a commit to brechtm/rinohtype that referenced this issue Feb 15, 2017

brechtm added a commit to brechtm/rinohtype that referenced this issue Feb 15, 2017

brechtm added a commit to brechtm/rinohtype that referenced this issue Feb 15, 2017

@leftler

This comment has been minimized.

Copy link

leftler commented May 11, 2017

Another option besides the suggestion of @giggio is add the flag --porcelain on to the command, this formats the text that is meant to be used with scripting.

Here is a comparision of the two with git push (running in powershell with 0.7.1 version of the posh-git module)

C:\Source [master ↑14]> git push
git : Everything up-to-date
At line:1 char:1
+ git push
+ ~~~~~~~~
    + CategoryInfo          : NotSpecified: (Everything up-to-date:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

C:\Source [master ≡]> git push --porcelain
To https://hsah.visualstudio.com/BlueSkyNA/_git/RXWorks
=	refs/heads/master:refs/heads/master	[up to date]
Done

However this does not work with checkout 😦

nicolasvan added a commit to red-gate/RedGate.Build that referenced this issue Oct 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment