Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How i can give a single branch access of my repository access to any user.

Ankit Verma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 23, 2023

Problem: 

We have some sensitive information in one of our code branches. 
And for now, we need to give access to one user because we don't want the user to checkout that particular branch in clone or any other pull command. 

 

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 24, 2023

Hi @Ankit Verma and welcome to the community!

It is not possible to restrict user access to a certain branch or branches only. When you grant a user access to a repo, this user can clone and pull all of the repo's branches, there is no way to prevent that.

You may want to look into submodules if you want to restrict access:

https://git-scm.com/book/en/v2/Git-Tools-Submodules

https://www.atlassian.com/git/tutorials/git-submodule

Instead of storing the code you don't want to share in a separate branch, you could create a repo instead and make it a submodule of your main repo. You can then grant access to a user to the main repo, but not to the submodule.


Another option would be to create a fork of your repo, delete the branch(es) you don't want to share from the fork, and then grant this user access to the fork. Please keep in mind that this will work if the branch is not the repo's main one, and if it has not been merged into other branches. If the branch you don't want to share has been merged into other branches, you would need to delete these other branches from the fork as well.

If you have any questions, please feel free to let me know.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events