【问题标题】:On-premises GIT repository with Visual Studio Team Services Project带有 Visual Studio Team Services 项目的本地 GIT 存储库
【发布时间】:2018-10-02 07:15:16
【问题描述】:

我们在本地安装了 GIT。那里有我们的代码存储库。 是否可以将此本地实例的存储库连接到 Visual Studio 团队服务项目?

所以它们显示在“代码”栏下?

vsts

我需要将它托管在本地,但请查看 VSTS 项目中的代码更改/提交和其他 GIT 内容

【问题讨论】:

    标签: azure-devops


    【解决方案1】:

    不,不支持在代码栏下显示其他存储库的文件或代码。您需要将该存储库导入到 VSTS 中的存储库。之后,如果您的本地 git 存储库中有更改,您可以将更新推送到 VSTS 存储库。

    【讨论】:

    • 非常感谢您回答我的问题和建议。
    【解决方案2】:

    您无法将本地 GIT 连接到 VSTS。但是,您可以使用 VSTS REST API 将代码从您的本地 GIT 推送到 VSTS。 通常,您将在本地 GIT 存储库上设置一个挂钩/触发器,以自动化复制过程。

    【讨论】:

      【解决方案3】:

      正如其他人所说,您可以拥有一个“git hook”,它基本上是一个 git 触发器,可以对某些事件采取行动。在这种情况下,在推送代码时,将其推送到 VSTS,但我假设您需要了解技术命令。

      我不得不反其道而行之,而且我做得又快又脏。这会一次性推动所有内容,而不是每次提交。这也可以赶上落后的回购。

      # Clone source repo (your local git repo)
      git clone some_repo_path_goes_here
      # I am skipping steps and assuming you are only syncing master branch.
      # I have code to get all branches down before proceeding, but not posting it here.
      # Assuming tags are on master branch..
      # Get all tags
      git fetch origin --tags
      
      # Test to see if remote alias already exists
      git ls-remote http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName
      # Add a remote alias
      git remote add any_name_123 http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName
      
      # push local repo to 'any_name_123'
      git push any_name_123 --all
      # optional: delete all tags before attempting to push local tags
      git push any_name_123 --delete `$(git tag -l)
      # push local tags to remote repo 
      git push any_name_123 --tags
      

      如果您愿意,您可以安排这项工作。我有一个 PowerShell 工作来做这件事,还有更多的功能来拉下分支。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多