Hiding commit from github

17,128

I had my access token in there

OOPs.

You cant hide commits but you can delete them from history.

You should use this tool:

https://rtyley.github.io/bfg-repo-cleaner/

It the prefect tool for this kind of task

BFG Repo-Cleaner

an alternative to git-filter-branch.

The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:

  • Removing Crazy Big Files
  • Removing Passwords, Credentials & other Private data

Examples (from the official site)

In all these examples bfg is an alias for java -jar bfg.jar.

# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa}  my-repo.git
Share:
17,128

Related videos on Youtube

N. Lowes
Author by

N. Lowes

Updated on June 04, 2022

Comments

  • N. Lowes
    N. Lowes over 1 year

    I pushed my code to github not realizing I had my access token in there. Which brings me to two questions

    1. Is there anyway to hide a commit?

    2. Is it really that bad to have your access token there?

    Thank yoou

    • toasted_flakes
      toasted_flakes over 7 years
      Once its pushed it's out there. You can remove it by rewriting history, but there are bots harvesting this automatically. You should invalidate your token.
    • Roland Starke
      Roland Starke over 7 years
      Your first question already has an answer here: stackoverflow.com/questions/448919/…
    • matbrgz
      matbrgz over 7 years
      Invalidate it and create a new one.
  • IceBotYT
    IceBotYT almost 3 years
    THANK YOU! This made me breathe a sigh of relief. @CodeWizard
  • IceBotYT
    IceBotYT almost 3 years
    There you go! :)