在使用源代碼管理時,我如何才能對源代碼的不同部分的用戶組擁有不同的權限? (While using source control, how can I have different permissions for groups of users for different parts of the source code?)


問題描述

在使用源代碼管理時,我如何才能對源代碼的不同部分的用戶組擁有不同的權限? (While using source control, how can I have different permissions for groups of users for different parts of the source code?)

我在應用源代碼管理時遇到問題。我嘗試了很多東西,但我無法弄清楚。在使用源代碼控制時,我希望能夠對源代碼的不同部分的用戶組擁有不同的權限。

我們曾經有一個包含整個 (Visual Studio) 解決方案和所有解決方案的大型存儲庫。項目。但是這次我們需要能夠管理源代碼不同部分(每個項目)的權限。這對於保護知識產權的某些部分很重要。

為了提供一點上下文說明:

  • 我們開發代碼(主要是Visual Studio (VS) 中的 C# 和 C++)。我們將 Azure‑DevOpsgit 存儲庫結合使用。
  • 我有一個 (VS) 解決方案,其中包含許多 (20+) 個項目(project1、project2、...)。
  • 這些項目中的大多數並不是真正獨立運行的(或者它不是這樣做是有意義的)。
  • 您可以考慮這些項目,例如庫、(可選)模塊/插件。
  • 每個項目都需要不同的特定領域知識來開發。
  • 對於某些測試,我們需要在一個大型解決方案中提供所有代碼,以便我們可以調試和設置斷點,例如

我嘗試了什麼:

很多東西,但最接近可行的解決方案是:

  • 我為每個項目創建了一個單獨的存儲庫。那麼我確實可以很好地管理每個用戶的權限。
  • 我為解決方案創建了一個存儲庫,我們將此存儲庫稱為 CombinedRepo
  • 將項目作為 git‑submodules 添加到 CombinedRepo.

這個設置在拉 CombinedRepo 時有效。使用 VS 的子模塊。我可以測試、調試和進行更改等。

但是,我對這個設置有以下問題:

  • 當我們工作時在 CombinedRepo 中並更改了其中一個子模塊的代碼,並希望提交這些更改,我們收到此錯誤:fatal: unexpected sequence in commit output.(這是使用時VS 提交)。
  • 反過來也行不通:

    參考解法

    方法 1:

    Visual Studio sees changes made in submodule folders, but fails to commit them.

    To workaround it, go to Team Explorer ‑ Manage Connections ‑ Local Git Repositories ‑ Add, browse to submodule folder and confirm with Add. Double click on the local repository created to open it.

    Now You can commit changes and push them to the remote origin like You would do just in original submodule repository.

    Than open again Your local repository containing the submodule folder, go to changes and commit them to include changed submodule state in main module.

    Here are some feature request links, you could follow them to get the latest news.

    In addition, If you only want to restrict users or team members from submitting code, we could set branch policy and disable the branch permission Bypass policies when pushing. Then all users need to create pull request to push the commit, and you could check the commit and approve the Pull Request.

    Update

    I want to be able to have different permissions for groups of users for different parts of the source code.

    Thanks for Stefan sharing.

    If we are using TFVC repo, we could configure the folder/file permission for groups of users. Check the pic below.

    enter image description here

    方法 2:

    When you have made a change in a submodule, you must switch to that submodule in order to successfully commit the change.

    (This information is taken from https://jonasr.app/2020/04/vs‑git‑subm/)

    (by StefanVito LiuAndrew McClement)

    參考文件

    1. While using source control, how can I have different permissions for groups of users for different parts of the source code? (CC BY‑SA 2.5/3.0/4.0)

#azure-devops #visual-studio #Git #git-submodules






相關問題

Visual Studio Online Build - Visual Studio SDK 和 Modellng SDK (Visual Studio Online Build - Visual Studio SDK and Modellng SDK)

有沒有辦法將現有的“功能”分配給史詩? (Is there a way to assign existing "feature" to epic?)

在路徑 Visual Studio Team Services 中找不到 curl (curl was not found in the path Visual Studio Team Services)

遠程 TFS 2015 到 Azure Devops(私有云)遷移 (Remote TFS 2015 to Azure Devops (private cloud) Migration)

無法再推送到 myProject.visualstudio.com (Can't push to myProject.visualstudio.com anymore)

使用 Visual Studio Code 連接 AzureDevOps Git 存儲庫時出現問題 (Issue in connecting AzureDevOps Git repo using Visual Studio Code)

適用於 Azure DevOps 和本地 PC 的發布生成事件 (Post Build event that works on both Azure DevOps and Local PC)

使用 Azure Devops 進行 CI/CD 部署 (CI/CD Deployment Using Azure Devops)

取回我創建的 DevOps 組織的所有權 (Get back ownership of DevOps organization that was created by me)

在使用源代碼管理時,我如何才能對源代碼的不同部分的用戶組擁有不同的權限? (While using source control, how can I have different permissions for groups of users for different parts of the source code?)

在 Azure DevOps 中自動更改用戶的訪問級別 (Automatically change access level on a user in Azure DevOps)

Azure DevOps Powershell 獲取與構建管道相關的工作項 (Azure DevOps Powershell get work item related to build pipeline)







留言討論