How to remove github with it?

My friend created a configuration file containing our apikey / token / secrets and .gitignore to ignore the specified file. Someone accidentally clicked on the main branch with the configuration file saved as another name and now shows it.

I was wondering if there is a way to remove this commit and the history of this commit.

I saw this (below) and I understand that this will remove the commit and re-click. But it still shows configuration information through history / changes:

 git reset --hard hash# git push -f origin branch 
+5
source share
1 answer

git-filter-branch can help you in your case:

Replace PATH-TO-YOUR-CONFIG-FILE with the path to your configuration file that you want to delete, and not just its name.

 git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch PATH-TO-YOUR-CONFIG-FILE' \ --prune-empty --tag-name-filter cat -- --all 

Add your configuration file to .gitignore to make sure that you didnโ€™t accidentally commit it, complete it and click it, as follows:

 echo "YOUR-CONFIG-FILE" >> .gitignore git add .gitignore git commit -m "Add YOUR-CONFIG-FILE to .gitignore" git push origin --force --all 
+2
source

Source: https://habr.com/ru/post/1269617/


All Articles