First, checkout a new branch of cf-terraform from vanilla_cf_prototype
git checkout vanilla_cf_prototype # from master
git checkout -b vanilla_cf_prototype_split
Then run the following -
git filter-branch -f --prune-empty --index-filter \
'for i in $(git ls-files | grep -v '^cf-manifest');
do git rm -r --cached --ignore-unmatch $i;
done' HEAD
This removes all files not in the cf-manifest directory, and removes all commits not touching these files due to the --prune-empty
option. This is based on
and example in the git filter-branch
man page. The for loop is added to make sure we remove files that were once in the history but have since been deleted.
This step can take a while!
Then, we want to move the files into a manifests/cf-manifest directory. I found this difficult to do while the initial empty commit remained, as the example from the man page would fail on the first commit as the git-update-index command would not create a file as there were no files to create. You can remove this using
git rebase --root
We can then run the filter-branch command to move all files in the cf-manifest directory to manifests/cf-manifest directory which makes more sense in
the paas-cf
repo
git filter-branch --index-filter \
'git ls-files -s | gsed "s@\tcf-manifest@\tmanifests/cf-manifest@" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
Then switch to your paas-cf
directory, and checkout a new branch
cd ../paas-cf
git checkout -b new_manifests
Then add the cf-terraform
directory as a remote to the paas-cf
repo
git remote add cf-terraform ../cf-terraform
Checkout the previous branch and rebase it -
git checkout vanilla_cf_prototype_split
git rebase new_manifests
You are now ready to put in a PR