Top Tags

Creating a git repository for a drupal theme

I have a Drupal theme, basicamaths - thanks to Khoi Vinh for creating it - and I have ported the theme from WordPress to Drupal. I have a few computers, and I need to be able to access the source code from all of them. The easiest solution I have found is to set up a GIT repository on my local NAS and store the source code there.

This is what I have done.

Set up my NAS to use SSH with public/private keys

cd
ssh me@nas.local
mkdir .ssh
scp ~/.ssh/id_rsa.pub me@nas.local:.ssh/authorized_keys

Create a local git repository

cd drupal_root
cd sites/localhost/themes/basicmaths/
git init
git add *
git commit -m "My initial commit"

Here I get the result

[master (root-commit) d5b949d] My initial commit
67 files changed, 4877 insertions(+), 0 deletions(-)

and many

create mode 100644 filename.type

messages

Create the shared GIT repository

ssh me@nas.local
mkdir repo
cd repo
mkdir drupal
cd drupal
mkdir themes
cd themed
mkdir basicmaths
cd basicmaths
git --bare init

I get the following output

Initialized empty Git repository in /vol/homes/me/repo/drupal/themes/basicmaths/ git config core.sharedrepository 1 #everything group readable and writable
git config receive.denyNonFastforwards true #do the merges on your local machine, and then push the result
find objects -type d -exec chmod 02770 {} \; #make sure permissions are set properly

On the local repository

git remote add origin ssh://me@nas.local//vol/homes/me/repo/drupal/themes/basicmaths

Update the .git/config configuration file with

[remote]
receivepack = /opt/bin/git-receive-pack
uploadpack = /opt/bin/git-upload-pack

then

git push origin master

I get

Counting objects: 77, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (77/77), done.
Writing objects: 100% (77/77), 397.00 KiB, done.
Total 77 (delta 5), reused 0 (delta 0)
To ssh://me@nas.local//vol/homes/me/repo/drupal/themes/basicmaths
* [new branch] master -> master
git checkout origin/master

and I get

Note: checking out 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

HEAD is now at d5b949d... My initial commit
git branch -f master origin/master Branch master set up to track remote branch master from origin.

git checkout master

Switched to branch 'master'