Quantcast
Channel: Installing and upgrading help
Viewing all articles
Browse latest Browse all 46804

Re: Got Git installed in my existing Moodle site. Here is How!

$
0
0
by Howard Miller.  

Ok... here's some more information.

The scenario: You have some Moodle code which has had hacks and changes made to it that you want/need to keep. It isn't in Git and you want to get the changes into git and go from there. If your Moodle is just 'vanilla' then stop here. You don't care, just get a fresh version from Git. Done.

The plan: what we want to do is to checkout of Git the *exact* version of Moodle that your current version started as before you started making changes. Having done that, it's trivial-ish to see what they difference is. I am assuming you know basic git commands and, caveat, this probably isn't the only way or even the easiest and is certainly not for the faint of heart!!

- pull the moodle repository from Git
- in your current version find the version.php file and get the build date out of it (e.g. '2.2.5+ (Build: 20121005)')
- in you Git Moodle, you want to find the exact commit that wrote the version file.
- then use the so-called 'pickaxe' command to locate the commit for your build (e.g. git log -S20120601 version.php). You should get one, but sometimes more if more than  one branch has the same build.
- if you have more, use git show on each commit to get the right one (the right branch). Having establised that simply create a branch and check it out using the commit SHA1 (e.g. git checkout -b mybasecode 3215955fd0e )
- what you have now is the 'clean' code without any of the changes. Make a quick sanity check to double check the basics looks the same.

Now the tricky bit - the hidden .git folder can now be copied over (recursively with contents) to your original code. Having a .git folder is all that makes something a git repository. So, go to your original code and type git status, and there's all the files you changed. You can now commit them or do whatever you like.

As Petr points out there are some gotchas (e.g. CVS can add stuff to the checked out files - evil but there you go) but if you're lucky that'll do it. You'll know it's gone wrong when git status shows that every file has changed wink


Viewing all articles
Browse latest Browse all 46804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>