Update from github with git? SOLVED

batonac

Member
I've created a little script that I run in the base dir of my Joomla install every time I want to update Fabrik:
Code:
#! /bin/sh
sudo -u www-data wget https://github.com/Fabrik/fabrik/archive/joomla3.tar.gz
sudo -u www-data tar -xvf joomla3.tar.gz --strip 1
sudo -u www-data rm joomla3.tar.gz
This works great and keeps all the permissions intact, but somehow it seems like a waist of bandwidth to re-download the complete Fabrik branch and overwrite all files every time I want to update. It also doesn't give me any visibility into which files have been altered on update, which I think would be a benefit.

Since I've never used git, I'd like to know if the developers have any recommendations on whether it's possible to install and update Fabrik in a Joomla 3.1 directory using only git, ultimately without downloading unnecessary branches and revisions (Google tells me 'git clone --depth=1' is key to get only the latest revision).
 
hi

I would suggest following the github tutorials.

First create an account on github if you do not have one, then to set up git follow this tutorial:
https://help.github.com/articles/set-up-git

then you would want to fork the fabrik repository into your own github account:
https://help.github.com/articles/fork-a-repo

Any where where they mention 'Spoon-Knife.git', replace with 'fabrik.git', likewise replace their example project name 'octocat' with 'Fabrik'

E.g.

Code:
git remote add upstream https://github.com/octocat/Spoon-Knife.git
becomes:

Code:
git remote add upstream https://github.com/Fabrik/fabrik.git
the Fabrik 3.1 code is in the joomla3 branch so you would need to switch from the master branch to that one:
Code:
git checkout joomla3
then to update your local copy:
Code:
 git pull upstream joomla3
 
Hmm... you answered my question, but that sure seems like a lot of work, especially since I just found that those steps can be replicated through two svn commands:
Code:
svn checkout https://github.com/Fabrik/fabrik/branches/joomla3
svn update
Unless I'm missing something here, it seems that Github's SVN support provides the most elegant solution :)
 
OK, I *think* I just found the coolest way to install & update fabrik from github on a Joomla install... (imo)
Code:
## creat dir for fabrik code
mkdir fabrik-source
 
## download fabrik for joomla 3
svn checkout https://github.com/Fabrik/fabrik/branches/joomla3 fabrik-source
 
## copy fabrik files into joomla
rsync -r --exclude=.svn fabrik-source/ .

To update fabrik:
Code:
## check for & download updated files
svn update fabrik-source
 
## copy updates into joomla
rsync -r --exclude=.svn fabrik-source/ .
 
Well, I never knew github had an SVN wrapper.

You could do something similar in git, and just clone directly from our master to your local machine with a single command. But the way Rob described, having your own clone on github you then check out to your local machine, is "better" in some ways.

-- hugh
 
rob & cheesegrits, thanks again for all the helpful advice that you gave here. I hope that eventually I will be able to fork fabrik and pitch in with the development workload.

I thought it might be good for the record to note that the most specific answer to my original question is this command:
Code:
git clone --depth=1 -b joomla3 https://github.com/Fabrik/fabrik.git fabrik-git
This command works very nicely to pull just the latest code from the joomla3 branch into a local directory (fabrik-git directory in the example above). The code can then be updated from github at any time by running these commands in that directory:
Code:
git fetch
git reset --hard
git clean -df
Finally, 'rsync -r fabrik-source-dir joomla-dir' can be used to copy the latest code into Joomla.

EDIT: Updated the code update instructions, I sure wish you could simply checkout with git using a single command...
 
Hmm... you answered my question, but that sure seems like a lot of work,
Well the first three lines are run just once as part of the set up.
The third line would only be run if you were switching branches, which leaves you with a single command to update with afterwards:

Code:
git pull upstream joomla3

less work in the end than what you are doing (which I'm not sure is even going to checkout the right branch?)
 
Thanks for your dedication to this topic rob!

I've been using git remote/checkout/pull now for all my new server setups and really liking it.

I have modified your original instructions to avoid the github account requirement (simply run these commands in the root directory of a joomla install):
Code:
git init .
git remote add upstream https://github.com/Fabrik/fabrik.git
git fetch upstream
git checkout -b joomla3 upstream/joomla3
To update then is as easy as:
Code:
git pull
 
  • Like
Reactions: rob
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top