Skip to content

Instantly share code, notes, and snippets.

Last active Aug 30, 2019
What would you like to do?
Commit the entire Drupal Commerce 2.x project including nested git repositories

First, as an alternative install this version of the Drupal Commerce:

composer create-project --repository= drugan/project-base some-dir --stability dev

If desired, you might not install it as a Drupal site, instead use it as a repository for all other of your projects (local or remote) to pull from. After composer installing open .gitignore file in the root of a repo and replace its content with the following:


Then in the repo root run this:

touch && chmod u+x

Fill the file with the content as it shown below.

Now, run this:

./ hide

After that as usual:

git add .
git commit -m 'My initial commit'

When you want to update this centralized repo just run this:

./ show
composer update

And after the update:

./ hide
git add .
git commit -m 'Updated and commited'

That way you have all the code of the repo commited as one huge git repository from which you can pull. Or, if you like, just use it as the repository for a particular Drupal Commerce 2.x site.

# @see:
# Prepend to or remove 'hidden' prefix from .git repositories
# Also, replace string "old" in file names:
# find -L ./ -name "old" -type f | rename -v "s/old/new/g"
# Also, replace stirng "old" in files:
# grep -rl old . | xargs sed -i 's/old/new/g'
if [ "$1" = "hide" ]
find -L ./ -name ".git" -type d | rename -v "s/.git/hidden.git/g"
find -L ./ -wholename "./hidden.git" -type d | rename -v "s/hidden.git/.git/g"
echo "HIDDEN!!!"
echo "All nested .git are turned into hidden.git."
echo "Now you can commit your changes on the repository and allow clones to pull ..."
exit 0
elif [ "$1" = "show" ]
find -L ./ -name "hidden.git" -type d | rename -v "s/hidden.git/.git/g"
echo "SHOWN!!!"
echo "All nested hidden.git are turned into .git."
echo "Now you can use composer to update the project and all the dependencies ..."
exit 0
echo "Enter \"hide\" or \"show\" as the first argument ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment