Reputation: 6806
I want to use the git-branch
npm module to detect my branch in the code, but Heroku doesn't show the .git folder, so git-branch
displays an error.
Is there a way to make that I can access that file?
If not, can I use a workaround, like copying the file and then restoring it, or stuff like that?
I'm auto-deploying from GitHub a Node.js app.
Upvotes: 0
Views: 41
Reputation: 32629
No, there is no way. Heroku will not send the .git
folder to the build.
Even if that folder were kept, you would always see the master
branch though, as it's always what you push to.
However, you can still retrieve the pushed GIT commit (not the branch) using the dyno metadata feature, which will set environment variables with various informations about your app. HEROKU_SLUG_COMMIT
will be the commit you deployed.
Upvotes: 1