【问题标题】:Pull the latest changes from git for a specifc repository从 git 中提取特定存储库的最新更改
【发布时间】:2017-02-20 18:14:54
【问题描述】:

我使用 vsts 个人访问令牌编写了一个自动化脚本,用于将项目中的所有存储库克隆到我的本地。脚本是

repoPaths=('repo1Url','repo2Url',etc...)
for i in "${repoPaths[@]}"
do
     git clone $repPaths[i] $localPath
done

现在,我正在尝试对上述 bash 脚本进行一些更改,以在 所有 repo 的可用克隆时提取最新更改。 p>

请提出建议。

【问题讨论】:

  • 当您运行 git clone 时,您会在此时获得最新的更改。
  • 您能否举例说明“克隆可用”是什么意思?
  • @Ashutosh Jindal :当您第一次运行脚本时,会创建克隆,现在说我对本地进行了一些更改,现在如果我再次运行脚本,我想将我的本地更改与最新的,目前还没有实现。
  • 您在寻找git pull

标签: git bash github azure-devops git-bash


【解决方案1】:

您可以有 2 个步骤,一个是提取 x 目录中的所有 repos,一个是克隆 x 目录中的所有 repos。这样的事情就足够了:

find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;

如此组合,它会是:

find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
repoPaths=('repo1Url','repo2Url',etc...)
for i in "${repoPaths[@]}"
do
     git clone $repPaths[i] $localPath
done

注意:如果它已经存在,这将导致一些看起来像 fatal: destination path 'repo1Url' already exists and is not an empty directory. 的错误

【讨论】:

    猜你喜欢
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2012-08-14
    • 2013-10-21
    • 1970-01-01
    • 2013-01-15
    • 2014-01-14
    相关资源
    最近更新 更多