Reputation: 111
I just added a Personal Access Token as seemingly mandated to use rhubv2.
Now "git push" fails, saying, "Push cannot contain secrets". This is with GitHub package Ecfun.
What do you suggest I do to fix this?
Thanks, Spencer Graves
I tried "git push" at both command line and within RStudio with the same effect. I enabled "Secret scanning" on GitHub to no apparent avail. I did web searches without finding anything I could understand and follow to fix this.
Upvotes: 0
Views: 131
Reputation: 111
I solved the problem as follows:
The error message told me which file was the problem. I had unwittingly included the Personal Access Token (PAT) in that file. I deleted that token that file. That wasn't enough, so I copied the rest of the file to a new file not under Git control and deleted the original file. That wasn't enough.
I created a new PAT with usethis::create_github_token()
.
I called gitcreds::gitcreds_set()
to register this token in the local Git credential and went to a URL provided in a message I got. Someplace, I don't remember how, I got the new PAT beginning "ghp_" and stored that with the GitHub entry in my password manager. (I use KeyPassXC.) This included editing (or creating) .renviron with content, GITHUB_PAT=ghp_ ... ["ghp_..." = the new PAT]
. Then I restarted R so it would read ".renviron".
"git push" still gave me apparently the same error message. Near the end, it said, "To push, remove secret from commit(s) or follow this URL to allow the secret. https://github.com/sbgraves237/Ecfun/security/secret-scanning/unblock-secret/ ...
. I clicked on something there to allow the secret. It then replaced that page of instructions with, "Secret allowed. You can now push this secret to the repository."
Then I did "git push", and it worked.
** I may have left out some necessary steps and included some unnecessary steps in this description, but I think I'm past that problem for the moment. With luck, my next "git push" will work fine. I can restore the file deleted with "git rm", etc. My process included "git add .", "git commit --amend", and "git rebase --continue". If the problem returns soon, I will return to this. I hope this helps others. Spencer Graves
Upvotes: 0