2016-10-12 90 views
0

我已经使用vsts个人访问令牌编写了一个自动化脚本,以将项目中的所有存储库克隆到本地。剧本是从git中获取特定存储库的最新更改

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

现在,我试图在上面的bash脚本的一些变化来拉的最新变化,如果克隆是从可用所有回购的的。

请建议。

+0

当你运行'git clone',你会得到那个时刻的最新变化。 – ElpieKay

+0

你可以用一个例子来详细说明'克隆是否可用'的含义吗? –

+0

@Ashutosh Jindal:当你第一次运行脚本时,克隆被创建,现在说我对本地做了一些改变,现在如果我再次运行脚本,我想合并我的本地更改与最新,目前这不是实现。 – Vinodh

回答

0

您可以有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.如果它已经存在

相关问题