Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DeveloperInfra/571046a2e5ac104302f3 to your computer and use it in GitHub Desktop.
Save DeveloperInfra/571046a2e5ac104302f3 to your computer and use it in GitHub Desktop.
BASH script to push multiple existing projects
#! /bin/bash
### My use case may be unique. We have 152 projects that we are transferring from VSS and SVN to Git.
### We don’t care about the prior source control history. We are starting fresh with the most recent
### version of each project.
for i in * ; do ### For each item in the active directory
if [ -d "$i" ]; then ### If the item is a folder
echo
DIR=$(basename "$i") ### Get the basename of the folder
read -p "Process $DIR (y/n)? " -n 1 -r ### Confirm you want to process the current folder
echo
if [ "$REPLY" = "y" ]; then
echo $DIR | clip ### Copy the folder name to the clipboard
cd $DIR
read -p "remote origin url: " URL ### Prompt for the clone URL
git init
git remote add origin $URL
git add .
git commit -m 'Initial commit from prior source control system.'
git push -u origin master
git status
cd ..
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment