Propogate changes across Git repos

I've been working on a project in its final phase - rounding off is never fun. That begin said, the project is mirrored into three repos that are (roughly) the same from a framework perspective. Changes made in one repo should propagate to the other two.

Forking is obviously a good and sane idea here. Unfortunately no fork strategy was used thus far and, well, time is ticking.

To work around this, I've decided to work in reverse gear and created a simple shell script to automate the process. The idea is:

1) Fix an issue on a feature branch in repo #1
2) Commit & push that branch
3) Add repo #1 as a remote in repo #2, #3 etc
4) Cherry-pick the latest commit
5) Push

First, add your 'root' git repo as a remote for all other repos you wish to propagate to:

$ git remote add origin

Confirm that the remote is added via:

$ git remote -v

Great. Next step, run the script:

# args are: 
# 1) root directory name  
# 2) comma-separated list of directories we wish to propagate to 

$ sh test1 test2,test3

Here's the shell script:


# set root directory
cd $1

# Get latest git commit hash, the current branch name and a list of directories to iterate over
root_branch=$(git rev-parse --abbrev-ref HEAD)  
root_commit=$(git rev-parse HEAD)

# Create branch, fetch remote pull, in cherry-pick commit and push
propogateGitChanges() {  
  git checkout -b $root_branch
  git fetch $root_remote
  git cherry-pick $root_commit
  git push --set-upstream origin $root_branch

# iterate over other directories and apply git changes
for i in $(echo $git_dirs| sed "s/,/ /g")  
  cd ..
  cd $i

exit 0  

Final note, IntelliJ (and other IDEs, I'm sure) have the concepts of shelving and patching.

Shelving is great, because it allows for quick-and-easy storing of changelists and individual files outside Git (as opposed to git-stash). The issue with shelving is that it doesn't allow for cross-project change propagation - changes a project-specific).

Patching is a better solution here, since it allows for creating .patch files of local changes that can be applied on other projects. You'll still have to go through the rigmarole of setting up branches, commit messages etc, though.

There are a million ways to do this and some are really short and succinct. This is just my answer - that is, until Git has a better native solution.