question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Git util failing in non git directory

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ehmickycommented, Feb 13, 2020

After discussing with @erquhart we concluded on the following solution: when there is no .git directory, the git utility should be an empty object and not report/print any errors.

This means:

  • we do not need to modify the utility’s API
  • users without a .git repository that do not use the git utility do not see any errors (i.e. same behavior as without the Build beta)
  • users without a .git repository that use the git 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.
0reactions
ehmickycommented, Feb 13, 2020

Done at #760.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found