Git util failing in non git directory
See original GitHub issueWhen running netlify build
in a folder that’s not a git repository, the git utility blows up with the message:
Error: Invalid base commit master
Command failed with exit code 128: git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
at findRef (/Users/mbc/.nvm/versions/node/v8.11.3/lib/node_modules/netlify-cli/node_modules/@netlify/git-utils/src/refs.js:43:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Steps to reproduce
run netlify build
in a folder that’s not a git repository
Expected behavior
Either ignore the git util or give a clear error message about needing a git repository to run.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Git error - Fatal: Not a git repository and how to fix it | Datree.io
This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right...
Read more >fatal: Not a git repository (or any of the parent directories): .git
The command has to be entered in the directory of the repository. The error is complaining that your current directory isn't a git...
Read more >Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
The error above, fatal: not a git repository (or any of the parent directories): .git , states that you tried to execute a...
Read more >fatal: not a git repository (or any of the parent ... - Initial Commit
In this article, we'll discuss the reasons for the error `fatal: not a git repository (or any of the parent directories): .git` and...
Read more >How to Fix the “fatal: not a git repository” Error - ContainIQ
In short, the fatal: not a git repository error indicates that your current working directory isn't tracked by Git. If you find yourself...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After discussing with @erquhart we concluded on the following solution: when there is no
.git
directory, thegit
utility should be an empty object and not report/print any errors.This means:
.git
repository that do not use thegit
utility do not see any errors (i.e. same behavior as without the Build beta).git
repository that use thegit
utility will most likely get an error about the property/method they are trying to use not existing. This is not the best error reporting experience, but we can improve this later.Done at #760.