This question is quite simple. I have a heroku app deployed, and I cannot find it's source code.
How can we retrieve the github repository url for a given heroku app via either the heroku CLI or by the heroku web interface?
Edit: yes, this has been troubling me for over a year now
I have tried heroku git:clone -a APP-NAME which copies the repository (from heroku?) to local. After cding into it, and trying to get the github remote url
git config --get remote.origin.url
but that returns blank. I also tried
git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I just tried
heroku slugs:download -a myappand getWarning: slugs:download is not a heroku command.
You would need to install the heroku/heroku-slugs plugin first, in order for that command to be recognized.
heroku plugins:install heroku-slugs
But try first, as you did
heroku git:clone -a APP-NAME
And then git log -1: that will give you the SHA1 of the latest commit.
You can then do on GitHub a Commit search by hash.
Example:
https://github.com/github/gitignore/search?q=hash%3A124a9a0ee1d8f1e15e833aff432fbb3b02632105&type=Commits
The OP stevec mentions in the comments using "How to clone all repos at once from GitHub?" to handle more than 100 repositories and (critically) download the private ones too (not just public).
That is: write a bash script that clones every repository on my account and somehow searches for a particular SHA.
I suggests a simple git log -1 SHA, or;, following "How to check if the commit exists in a Git repository by its SHA-1":
git rev-parse -q --verify "$sha^{commit}" > /dev/null
The OP adds:
I realised your initial solution definitely works (even for private repos).
heroku git:clone -a APP-NAME git log -1, https://github.com/search?q=hash%3A<SHA>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With