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.

Cannot identify HEAD for git repository.

See original GitHub issue

I have django 1.8 python 3.5 raven 5.26.0 And I have followed django integration after executing:

python3 projectname/manage.py raven test

I have got raven.exceptions.InvalidGitRepository: Cannot identify HEAD for git repository at /home/faja/Pulpit/Projekty/mainProjectFolder/djangoFolder/mainAppWithSettings

My project structure


zdobadzszczyt/
└── zdobadzszczyt
    ├── config
    ├── landingpage
    │   └── migrations
    ├── socialauth
    │   └── migrations
    ├── static
    ├── staticfiles
    │   └── admin
    │       ├── css
    │       ├── img
    │       │   └── gis
    │       └── js
    │           └── admin
    ├── templates
    └── workout
        ├── management
        │   ├── commands
        └── migrations

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

52reactions
laurentScommented, Nov 2, 2016

I think it’s a documentation issue. I followed the quick installation instructions on my sentry instance, which suggests this line

'release': raven.fetch_git_sha(os.path.dirname(__file__)),

in your settings.py. But if your settings.py is like mine one folder down from your git root folder, then you get the error you describe (because of this: https://github.com/getsentry/raven-python/blob/master/raven/versioning.py#L22). Instead follow https://docs.sentry.io/clients/python/integrations/django/ and replace the line with:

'release': raven.fetch_git_sha(os.path.dirname(os.pardir)),

and you’re in business!

9reactions
Designer023commented, Dec 20, 2017

I have tried all of the above and it didn’t work for a Django Project I have been working on. We’re using Heroku also if that is relavant. What eventually worked for me is:

'release': raven.fetch_git_sha(os.path.abspath(BASE_DIR)),

Where BASE_DIR is set in the settings file which resides in the project folder one level up from the root of the project. The project settings file is specified using an environmental variable:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Hope this helps anyone else with a similar problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Raven fails to identify HEAD git revision for Django on Heroku
Raven fails to identify HEAD git revision for Django on Heroku ... remote: 'Cannot identify HEAD for git repository at %s' % (path,))...
Read more >
Setting a valid HEAD on your Git repository | Fisheye
The Not a valid object name HEAD in the message above indicates that your Git HEAD ref is invalid. This means that Fisheye...
Read more >
Cannot identify HEAD for git repository. - Bountysource
I have django 1.8 python 3.5 raven 5.26.0. And I have followed django integration after executing: python3 projectname/manage.py raven test.
Read more >
Why does git not recognise my local repository? - Stack Overflow
1. My guess (and probably most common reason for this): you think you're in the right directory but for one reason or another...
Read more >
How to Fix the “fatal: not a git repository” Error - ContainIQ
Make sure you correctly typed the name of the directory. · Check that you correctly created the repo. If the directory doesn't contain...
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