Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need to restrict user to access old versions of bitbucket files

Raj Kumar Samakari March 18, 2022

Hi

We have a file with the user name and password and some text in a repo.
we committed that repro later we under we should not put password public.
So we made changes to the file and removed the password.
But still, if we open the file history/versions if we check the old version the password will be still avalibile.
since we need to restrict that version to be accessed by users. 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2022

Hi @Raj Kumar Samakari and welcome to the community.

It is not possible to restrict access to certain files or commits in a repo.

My suggestion would be rewriting history to remove this file from the repo's history (and afterwards commit it again, without the password).

One tool you could use for removing the file from the repo's history is BFG:

If you check the examples on that page, it is possible to use it with the flag --delete-files in order to delete the file from the repo's history.

Please note:

  • Rewriting history means that the commit hashes of the repo will change. It would be good to communicate this with your team, and also ask them to take a new clone of the repo after you finish this process, to avoid pushing any of the old commits back.
  • Make sure you take a backup of the repo prior to doing any changes (a clone with the --mirror flag, other than the one where you use BFG) in case anything goes wrong, as rewriting history involves destructive operations. I would also suggest pushing any changes to a newly created empty repo first, to check if the repository is in good shape before you push to the repo you are working on.

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events