Link git to existing installation?

Link git to existing installation?

by Kris Jacobs -
Number of replies: 5

I installed Moodle on FreeBSD using the ports tree.

I was just notified that an upgrade is available, so I read the Upgrading instructions, and found this:

https://docs.moodle.org/31/en/Administration_via_command_line#Upgrading


I would like to do the CLI upgrade - however git throws an error:

root@NETMONv2:/usr/local/www/moodle

# git pull

fatal: Not a git repository (or any of the parent directories): .git


I think I understand what's going on - because I used FreeBSD's port to install Moodle 3.1 initially, I'm probably not "linked up" to the git repository.

Is it possible to link my installation after-the-fact so I can use the git pull method of upgrading?

Thank you!

-Kris

Average of ratings: -
In reply to Kris Jacobs

Re: Link git to existing installation?

by Helson C -

You need start a respository inside the folder

cd /usr/local/www/moodle

git init

In reply to Helson C

Re: Link git to existing installation?

by Kris Jacobs -

Thanks - I did that.  Then what?  There has got to be more to it than that.

I've been fiddling with it for hours, just had to restore /usr/local/www/moodle/ from backup.


For now I'm just going to turn off update checking & notification.

In reply to Kris Jacobs

Re: Link git to existing installation?

by Ken Task -
Picture of Particularly helpful Moodlers

Think everyone's on a different time zone ... or had to work (necessary evil).

'sideload" the git acquired code.

Backup current code directory and get a DB dump.
from /usr/local/www/

git clone git://git.moodle.org/moodle.git sideload
cd sideload
Change 2# to your current version seen by
fgrep '$release' ../moodle/version.php

git branch --track MOODLE_2#_STABLE origin/MOODLE_2#_STABLE
git checkout MOODLE_2#_STABLE

git branch -a to see all the branches of Moodle code knows about
and to see which is't set to track.
* should indicate the same version in git branch and git checkout commands you issued.

Now we copy the hidden .git directory to the current code directory.

cp -rp .git ../moodle/

cd ../moodle/
git branch -a (to check)
git pull

May as well finish the job:
in /usr/local/moodle/
php admin/cli/cron.php
php admin/cli/maintenance.php --enable
php admin/upgrade.php --non-interactive
php admin/cli/maintenance.php --disable

The above will beget a in-series minor update ... which is always recommended before 'upgrading' which means moving up a series version - ie, 2.9.x -> 3.0.x


Check ownerships/permisisons.
Hit site with browser, login, go to Notifications.
Check updates.

Now to upgrade (I'd march to next highest, not hyperjump) ... let's say you are at 2.9.highest and wanna upgrade to 3.0.highest ... first hop upwards.

cd /usr/local/moodle/

git branch --track MOODLE_30_STABLE origin/MOODLE_30_STABLE
git checkout MOODLE_30_STABLE

git branch -a should now * Moodle 30.

Then the other commands to finish.

php admin/cli/maintenance.php --enable
php admin/upgrade.php --non-interactive
php admin/cli/maintenance.php --disable

Check ownerships/permisisons - reset accordingly.

Hit site with browser.  Login.  Notifications.  Check Updates.

*BACKUP*

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Link git to existing installation?

by Kris Jacobs -

Perfect, thank you so much Ken!

I'm running v3.1.1.  The Admin Notifications page says v3.1.2 is available.

I got the git sideload done per your instructions, but the CLI commands are telling me I don't need to update.

Maybe v3.1.2 code isn't present in my git repo for some reason?

See below CLI output, thanks.


root@NETMONv2:/usr/local/www/moodle

# git branch -a

* MOODLE_31_STABLE

  master

  remotes/origin/HEAD -> origin/master

  remotes/origin/MOODLE_13_STABLE

  remotes/origin/MOODLE_14_STABLE

  remotes/origin/MOODLE_15_STABLE

  remotes/origin/MOODLE_16_STABLE

  remotes/origin/MOODLE_17_STABLE

  remotes/origin/MOODLE_18_STABLE

  remotes/origin/MOODLE_19_STABLE

  remotes/origin/MOODLE_20_STABLE

  remotes/origin/MOODLE_21_STABLE

  remotes/origin/MOODLE_22_STABLE

  remotes/origin/MOODLE_23_STABLE

  remotes/origin/MOODLE_24_STABLE

  remotes/origin/MOODLE_25_STABLE

  remotes/origin/MOODLE_26_STABLE

  remotes/origin/MOODLE_27_STABLE

  remotes/origin/MOODLE_28_STABLE

  remotes/origin/MOODLE_29_STABLE

  remotes/origin/MOODLE_30_STABLE

  remotes/origin/MOODLE_31_STABLE

  remotes/origin/master


FreeBSD 10.3-RELEASE-p4

root@NETMONv2:~

# fgrep '$release' /usr/local/www/moodle/version.php

$release  = '3.1.1 (Build: 20160711)'; // Human-friendly version name


FreeBSD 10.3-RELEASE-p4

root@NETMONv2:/usr/local/www/moodle

#  php admin/cli/maintenance.php --enable

== Maintenance mode (http://moodle.calhouncountymi.gov) ==

Your site is currently in CLI maintenance mode, no web access is allowed.

FreeBSD 10.3-RELEASE-p4

root@NETMONv2:/usr/local/www/moodle

# git pull

Already up-to-date.

FreeBSD 10.3-RELEASE-p4

root@NETMONv2:/usr/local/www/moodle

# php admin/cli/upgrade.php              

No upgrade needed for the installed version 3.1.1 (Build: 20160711) (2016052301). Thanks for coming anyway!


FreeBSD 10.3-RELEASE-p4

root@NETMONv2:/usr/local/www/moodle

#  php admin/cli/maintenance.php --disable

== Maintenance mode (http://moodle.calhouncountymi.gov) ==

Maintenance mode has been disabled and the site is running normally again


In reply to Kris Jacobs

Re: Link git to existing installation?

by Kris Jacobs -

HA!  I just refreshed my ports tree - /usr/ports/www/Moodle31 is now on v3.1.2  =)

Maintainer of the port = wen@freebsd.org

Thanks wen!


FreeBSD 10.3-RELEASE-p4

root@NETMONv2:/usr/ports/www/moodle31

# portmaster moodle31


Opened web interface, it stated it needed to update database, etc. - then landed on Admin page happily stating:

Your Moodle code is up-to-date!


And I'm' done.  Thanks again Ken.

-Kris