[英]Pull the latest changes from git for a specifc repository
I have written an automated script using vsts personal access token to clone all the repositories in a project to my local. 我使用vsts个人访问令牌编写了一个自动化脚本,将项目中的所有存储库克隆到本地。 The script is
该脚本是
repoPaths=('repo1Url','repo2Url',etc...)
for i in "${repoPaths[@]}"
do
git clone $repPaths[i] $localPath
done
Now, I'm trying to make some changes in the above bash script to pull the latest changes if the clone is available from all of the repo's . 现在,我尝试在上述bash脚本中进行一些更改,以在所有存储库中都可以使用该克隆的情况下,进行最新更改。
Please suggest. 请提出建议。
You could have 2 steps, one to pull all repos in x directory and one to clone all repos in x directory. 您可能有2个步骤,一个步骤将x目录中的所有存储库拉入,而另一个步骤则将x目录中的所有存储库克隆。 Something like this should suffice:
这样的事情就足够了:
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
So combined, it'd be: 如此组合,将是:
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
Note: This will result in some errors that look like fatal: destination path 'repo1Url' already exists and is not an empty directory.
注意:这将导致一些
fatal: destination path 'repo1Url' already exists and is not an empty directory.
错误fatal: destination path 'repo1Url' already exists and is not an empty directory.
if it already exists 如果已经存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.