Можно ли 'мерзавца клон' несколько Git репозиториев с помощью одной команды (например: мерзавец клон "1.git, 2.git, 3.git .." в одном локальном каталогеОформить несколько репозиториев git в одном локальном каталоге?
BR
Можно ли 'мерзавца клон' несколько Git репозиториев с помощью одной команды (например: мерзавец клон "1.git, 2.git, 3.git .." в одном локальном каталогеОформить несколько репозиториев git в одном локальном каталоге?
BR
Вы можете найти пример сценария, как this one:
Я этот файл называется «клон», содержащий URL-адреса нескольких GIT РЕПО
Snippet (взяты из djangosites.com Удивительный сайт должен посетить..):
$ cat clone
https://github.com/igorsobreira/igorsobreira.com https://github.com/ella/ella https://github.com/divio/django-cms/ https://github.com/palewire/palewire.com https://github.com/jabapyth/jfcom https://github.com/humanfromearth/snippify https://github.com/scaphilo/koalixcrm https://github.com/jlev/Boycott-Toolkit https://github.com/jbalogh/zamboni/ https://github.com/ASKBOT/askbot-devel https://github.com/emesik/djiki https://github.com/vicalloy/LBForum https://github.com/agiliq/agiliq https://github.com/bartTC/dpaste.de https://github.com/bartTC/django-paste https://github.com/bartTC/dpaste_de/ https://github.com/fotochest/fotochest https://esp.mit.edu/git/esp-project.git https://github.com/titan2x/bashoneliners.git
По-видимому, это сложнее клонировать несколько сделок РЕПО сразу (
git clone <repo1> <repo2> ... <repon>
не работает). Так что я написал этот короткий код Баш, чтобы заставить его работать:Код:
atm in /home/atm/git/django_repos
$ for f in `cat clone`; do `git clone $f`; done
Вы нашли бы много больше gist.github.com, как this one, чтобы клонировать все операции РЕПО с GitHub:
#!/bin/bash
#
# Copyright 2011, Tim Branyen @tbranyen <[email protected]>
# Dual licensed under the MIT and GPL licenses.
#
# Automatically clone single or multiple repos into a folder,
# great for setting up a git projects folder.
#
# Install: curl https://gist.github.com/raw/902154/github.sh > /usr/local/bin/gh
# chmod +x /usr/local/bin/gh
#
# Internal properties
[email protected]:
GITHUB_USERNAME=$(git config --global github.user)
function main {
# Improperly configured user
detect_user
# Missing arguments
args=$1
if [ -z $args ]; then
echo '
gh: try ''`gh --help`'' for more information
'
exit
fi
# Display help text
if [ $args = '--help' ]; then
echo '
Clone repos from your GitHub
gh repo1 repo2
Clone repos from others GitHub
gh username/repo1 username/repo2
Clone mixed repos:
gh repo1 username/repo2
Clone line separated repos from file:
cat file | xargs gh
'
exit
fi
# Parse arguments and clone repos.
find_repos
}
function detect_user {
# If no username configured, attempt to pull from git --config
if [ -n "$GITHUB_USERNAME" ]; then
USERNAME=$GITHUB_USERNAME
else
echo '
gh: missing username
configure username with ''`git config --global github.user username`''
'
exit
fi
}
function find_repos {
for repo in $args; do
# If a user provides the parameter username/repo pull in that specific repository.
if [ `awk -v repo="$repo" -v delimit="/" 'BEGIN{print index(repo,delimit)}'` -ne 0 ]; then
echo "Pulling in $repo";
git clone $GITHUB_PREFIX$repo.git
# Default to you.
else
echo "Pulling in $USERNAME/$repo";
git clone $GITHUB_PREFIX$USERNAME/$repo.git
fi
done
}
main $*
Я создал образец сценария для своего проекта. Наш проект включает множество репозиториев, которые нужно клонировать, когда новый человек присоединяется к команде.
Итак, вот содержание скрипта, которое вы можете сохранить в некоторых исполняемых файлах и выполнить.
echo -n Please Enter your GitHub Username:
read username
echo -n Please Enter your GitHub Password
read -s password // doesn't echoes the password on screen
git clone
https://$username:[email protected]/location/reponame1.git
https://$username:[email protected]/location/reponame2.git
....
https://$username:[email protected]/location/reponamen.git
Его тихое полезна, чтобы избежать скучных ручных усилий и обеспечить, чтобы все необходимые проекты были клонированы за один раз.
Надеюсь, что мой ответ поможет кому-то еще.
Не совсем практично – holms
Да. Я понял, что проблема с скриптом ... ваш пароль содержит @, он не работает как сама команда как @ после пароля. Придется работать над этим. Но это работает иначе. –
Что значит точно? Вы хотите «объединить» все репозитории в одном? – Atropo
Нет. Например: У меня: x.git, y.git, z.git ... Чтобы проверить их, я должен выполнить: git clone x.git, git clone y.git, git clone z.git, ... Я хочу, чтобы git clone несколько git-repos с командой 1. Возможно ли это? – vir2al
Ну, вы могли бы сделать это в одной команде *, которую вы вводите *, но все равно будет выполняться несколько команд. Например, 'echo x.git y.git z.git | xargs -n 1 -d '' git clone'. – twalberg