Skip to content
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

error: "git" returned status 1 #10

Open
xinde opened this issue Jan 4, 2017 · 27 comments
Open

error: "git" returned status 1 #10

xinde opened this issue Jan 4, 2017 · 27 comments

Comments

@xinde
Copy link

xinde commented Jan 4, 2017

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

@kevintechie
Copy link
Contributor

kevintechie commented Jan 10, 2017

I get the same error.

Linux Mint
vs code 1.8.1
git 2.11.0

@ajsb85
Copy link

ajsb85 commented Jan 18, 2017

I get the same error.

image

@vector-of-bool
Copy link
Owner

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?

@ajsb85
Copy link

ajsb85 commented Jan 20, 2017

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

@d-schiffner
Copy link
Contributor

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

@ajsb85
Copy link

ajsb85 commented Jan 20, 2017

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

@d-schiffner
Copy link
Contributor

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

@vector-of-bool
Copy link
Owner

@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.

@ajsb85
Copy link

ajsb85 commented Jan 23, 2017

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

@d-schiffner
Copy link
Contributor

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

@kevintechie
Copy link
Contributor

kevintechie commented Jan 23, 2017

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
Copy link
Contributor

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.

@vector-of-bool
Copy link
Owner

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

@d-schiffner
Copy link
Contributor

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

@jonathanfishbein1
Copy link

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

@kevintechie
Copy link
Contributor

@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.

@ajsb85
Copy link

ajsb85 commented Feb 22, 2017

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

@kevintechie
Copy link
Contributor

kevintechie commented Feb 22, 2017

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

#12

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

@vector-of-bool
Copy link
Owner

Is any still experiencing this exact issue?

@jsvg
Copy link

jsvg commented May 15, 2017

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.

@kevintechie
Copy link
Contributor

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

@vector-of-bool
Copy link
Owner

Anyone still experiencing this issue in the latest version?

@endquote
Copy link

endquote commented Jul 4, 2017

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

@SeanRoberts
Copy link

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

@xiagw
Copy link

xiagw commented Mar 30, 2019

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

yes, same error.
image

@stephen-commits
Copy link

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.

@ngrcode
Copy link

ngrcode commented Oct 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests