Hi,
I am also working in a firm and we have many projects on git .In a single
workspace we import projects from git which is time consuming. I am trying
to automate that process.
This is so far i have designed.
our remote url to access the projects from git is git clone
https://[email protected]/scm/emplifecycle/p
<https://[email protected]/scm/emplifecycle/envy.git>roject1.git
similarly are project2 project3 and so on..
so i want to loop for these projects.
Any improvements/suggestions
#!/bin/bash
# import multiple remote git repositories to local CODE dir
# settings
remoteHost=git.blackrock.com
remoteUser=kchawla
remoteDir="~/scm/emplifecycle/"
branchName="PeopleMover_FEB_2017"
remoteRepos=$(ssh -l $remoteUser $remoteHost "ls $remoteDir")
localCodeDir="/C/Work/Workspaces/PeopleMover_FEB1_2017/WebApp"
# if no output from the remote ssh cmd, bail out
if [ -z "$remoteRepos" ]; then
echo "No results from remote repo listing (via SSH)"
exit
fi
# for each repo found remotely, check if it exists locally
# assumption: name repo = repo.git, to be saved to repo (w/o .git)
# if dir exists, skip, if not, clone the remote git repo into it
for gitRepo in $remoteRepos
do
localRepoDir=$(echo ${localCodeDir}${gitRepo}|cut -d'.' -f1)
if [ -d $localRepoDir ]; then
echo -e "Directory $localRepoDir already exits, skipping ...\n"
else
cloneCmd="git clone https://$remoteUser@$remoteHost/$remoteDir"
cloneCmd=$cloneCmd"$gitRepo --branch branchName --single-branch
$localRepoDir"
cloneCmdRun=$($cloneCmd 2>&1)
echo -e "Running: \n$ $cloneCmd"
echo -e "${cloneCmdRun}\n\n"
fi
done
--
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.