简体   繁体   中英

if a branch is never merged into master, will deleting that branch also remove its commits from the repo?

Our normal development pattern is to push changes to a branch, then submit a PR from that branch to master. We discovered some issues with the branch (contains old commits with data we don't want in the repo), and want to remove them. It's OK to delete the branch -- nothing is merged yet.

The question is: will deleting this branch remove the commits that contain data?

The following help article shows how to do perform the cleanup. It's recommended to contact support as part of the process to purge data on GitHub.

https://help.github.com/en/articles/removing-sensitive-data-from-a-repository

Other git hosting platforms may not delete all unreferenced data. Azure Devops, for example doesn't perform server side garbage collection.

Also make sure all developers purge the commits from their local repo.

If the data contains credentials, certificates or encryption keys, consider them compromised and revoke/recycle them!

If you delete the branch and no other branch or tag references those commits, they will eventually be deleted, yes.

Most Git repositories have the reflog enabled, which means that the history of any branch is preserved for a defined period of time. Objects which are referenced by the reflog are not deleted so that recovery can occur if you've made a mistake. Even after the reflog is expired, the objects may still live in the repository until a future git prune (usually invoked by git gc ) cleans them up.

If the commits contain something you very much want deleted (eg, secrets or personal information), you can delete them and then contact GitHub ( as documented ) to have those objects purged. If they're secrets, you should rotate them on the assumption the information is compromised.

If the data is just unused stuff that you don't care about very much but just don't want checked in (eg, useless temporary files), then you needn't contact GitHub support; the data will be cleaned up (or not) on GitHub's side as it's convenient for them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM