You can use multiple deploy keys for Github created with ssh-keygen following with these steps.
You have to add to your ~/.ssh/config
If you haven’t added your github name on git:
git config --global user.name "yourgithubname"
git config --global user.email "firstname.lastname@example.org"
Then clone your repository specifying your custom host, adapting what github suggest to you on repo page:
git clone git@github_deploy_key_1:yourgithubname/your-repo.git
If you have enabled push permissions you can use this deploy key even to update the repository.
In this way you can keep a server clean from your github passepartout and add only the keys it needs.
To delete git files uploaded accidentally to GitHub (or any other public repository) do these steps:
- Download https://rtyley.github.io/bfg-repo-cleaner/ as suggested by GitHub
- git clone –mirror GIT_REPOSITORY_URL
- cd path/to/cloned/repository
- Download BFG
- java -jar /path/to/download/dir/bfg-VERSION.jar –delete-files filename.ext
- Run the command specified by BFG (usually git reflog expire –expire=now –all && git gc –prune=now –aggressive)
- git push
If you get an error on pull, probably you haven’t cloned the repository as step 2.
Browsing the public history, any reference to the filename.ext file disappear.
Read more about BFG and the –mirror option on this discussion.