Skip to content

Instantly share code, notes, and snippets.

@DeveloperInfra
Created July 25, 2014 19:52
Show Gist options
  • Save DeveloperInfra/a5fcbb69d54927e4fae0 to your computer and use it in GitHub Desktop.
Save DeveloperInfra/a5fcbb69d54927e4fae0 to your computer and use it in GitHub Desktop.
BASH script to merge and push multiple projects
#! /bin/bash
### My use case may be unique. We have 146 projects that we transferred from VSS and SVN to Git.
### We made file and code changes in each project within a local branch. Now we want to merge
### the changes back into the develop branch. We also want to push the changes up to origin.
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
cd $DIR
git checkout develop
git pull ### Always pull before you merge/push to get the latest version
read -p "Merge (y/n)? " -n 1 -r ### Confirm you want to merge
echo
if [ "$REPLY" = "y" ]; then
git merge --no-ff VS2012
git push origin develop
git status
read -p "Delete the VS2012 branch (y/n)? " -n 1 -r ### Confirm you want to delete the branch
echo
if [ "$REPLY" = "y" ]; then
git branch -d VS2012
fi
fi
cd ..
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment