vscode-gitflow icon indicating copy to clipboard operation
vscode-gitflow copied to clipboard

error: "git" returned status 1

Open xinde opened this issue 8 years ago • 27 comments
trafficstars

when I select 'Initialize repository for gitflow' ,at last step,an error occurred

error: "git" returned status 1


windows 10 vs code 1.8.1

xinde avatar Jan 04 '17 14:01 xinde

I get the same error.

Linux Mint vs code 1.8.1 git 2.11.0

kevintechie avatar Jan 10 '17 23:01 kevintechie

I get the same error.

image

ajsb85 avatar Jan 18 '17 10:01 ajsb85

I'm unable to reproduce the issue on my local systems, could I see some of the console output from the developer console when you try to run the failing commands?

vector-of-bool avatar Jan 20 '17 05:01 vector-of-bool

Hi @vector-of-bool

I can see this message with the command > Gitflow: Initialize repository for gitflow

[Extension Host] [gitflow] Execute git config --get gitflow.branch.master
[Extension Host] [gitflow] Command "git" returned code -4058: 
spawn git ENOENT: Error: spawn git ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
WARNING: Promise with no error callback:94
Object {exception: null, error: Error: spawn git ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess…, promise: n.C…s.d…e._oncancel, handler: undefined, id: 94…}
spawn git ENOENT

ajsb85 avatar Jan 20 '17 08:01 ajsb85

I would believe, this error comes, because git is not in the path.

I had a look in the vscode discovery for the git config. They are using the @IGitService to access the internal git, which automatically detects the os specific git installation

d-schiffner avatar Jan 20 '17 12:01 d-schiffner

Hi @d-schiffner

Git works in VS Code.

image

I have only the GitHub Desktop app and their shell.

In the PATH it's not ready.

image

ajsb85 avatar Jan 20 '17 14:01 ajsb85

Hi @ajsb85,

yes, VS Code searches internally for the correct path and then uses it. However, this plugin does not use the available service but instead calls git via shell, which is not defined.

Not tested workaround: Add git to path

d-schiffner avatar Jan 20 '17 15:01 d-schiffner

@d-schiffner, thanks for the tips! I wasn't aware VSCode did that to find git. That should be helpful in fixing this problem now that I have a lead on what it actually going on.

vector-of-bool avatar Jan 20 '17 21:01 vector-of-bool

Hi @vector-of-bool so just use vscode.workspace.getConfiguration("git").get("path", "git") instead of "git"

ajsb85 avatar Jan 23 '17 18:01 ajsb85

This only works, if you have defined a path there, or fall back to the normal assumption, that git is available from the path.

d-schiffner avatar Jan 23 '17 18:01 d-schiffner

Git is in my path on linux, but I still get the error.

My debug console output is different, however:

[gitflow] Execute git config --get gitflow.branch.master
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git config --get gitflow.branch.develop
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git rev-parse --quiet --verify HEAD
[gitflow] Command "git" returned code 1: 
[gitflow] Execute git symbolic-ref HEAD refs/head/master
[gitflow] Command "git" returned code 0: 
[gitflow] Execute git commit --allow-empty --quiet -m Initial commit
[gitflow] Command "git" returned code 0: 
[gitflow] Execute git branch --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch -r --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch -r --no-color
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Execute git branch --no-track develop master
[gitflow] Execute git checkout develop
[gitflow] Command "git" returned code 128: fatal: HEAD not found below refs/heads!
[gitflow] Command "git" returned code 1: error: pathspec 'develop' did not match any file(s) known to git.

kevintechie avatar Jan 23 '17 19:01 kevintechie

So it turns out that my error is caused because I was using a newly initialized repository without any commits. The git rev-parse --quiet --verify HEAD returned nothing causing git symbolic-ref HEAD refs/head/master to be executed. Unfortunately, refs/head/master is not a valid link. The path head should be heads.

The invalid HEAD state causes the rest of the script to fail and the extension return code to be 1.

The typo is in line 121.

kevintechie avatar Feb 03 '17 17:02 kevintechie

Thanks, @d-schiffner, for the awesome PR. I've just pushed out the changes, and, hopefully, this will fix the problems with Git.

vector-of-bool avatar Feb 17 '17 03:02 vector-of-bool

@vector-of-bool: You're welcome. Keep up the good work ;)

d-schiffner avatar Feb 17 '17 08:02 d-schiffner

Hello I seem to still be experiencing this problem and suggestions on how I can fix it?

jonathanfishbein1 avatar Feb 21 '17 19:02 jonathanfishbein1

@jonathanfishbein1 are you starting with a repository that doesn't have any commits? If so, there is a bug that is not fixed by the latest release.

kevintechie avatar Feb 22 '17 17:02 kevintechie

After the changes in the new version of TypeScript you need to review in deep this extension @vector-of-bool

ajsb85 avatar Feb 22 '17 17:02 ajsb85

I have created a pull request to fix the typo in the symbolic-ref:

https://github.com/vector-of-bool/vscode-gitflow/pull/12

This bug will also cause the error where git will return 1.

kevintechie avatar Feb 22 '17 19:02 kevintechie

Is any still experiencing this exact issue?

vector-of-bool avatar Mar 28 '17 15:03 vector-of-bool

Still experiencing here. Latest OSX and VS Code. Tried in both newly initialized git projects (with and w/o commits), and in existing projects. No luck. VSCode doesn't appear to have any other problems accessing git. Git is in path.

jsvg avatar May 15 '17 22:05 jsvg

You will continue to get this error until the next release or you can clone the latest code and build it yourself.

kevintechie avatar May 15 '17 22:05 kevintechie

Anyone still experiencing this issue in the latest version?

vector-of-bool avatar Jun 23 '17 00:06 vector-of-bool

I just installed the extension on vscode for Mac and got this error after running "initialize repository for gitflow"

endquote avatar Jul 04 '17 19:07 endquote

I also got the same error on VS Code for Mac. All other git functions work as expected.

SeanRoberts avatar Jul 11 '17 18:07 SeanRoberts

I just installed the extension on vscode for Mac and got this error after running "initialize repository for gitflow"

yes, same error. image

xiagw avatar Mar 30 '19 13:03 xiagw

This issue is still opened so I put it here. I faced the same problem when I created a new project, the solution I found is create the develop branch manually and initialize git flow command worked for me. I hope it will work for people facing the same problem.

stephen-commits avatar Jun 06 '21 17:06 stephen-commits

this is bcs you haven't had master and develop as branch in your local

ngrcode avatar Oct 24 '23 08:10 ngrcode