GitForLunarDevs
Introduction
This is a skeleton page based on a discussion with Ratler on #lunar. Git can be easier than the man pages would suggest as long as someone shows you the way.
The page name is a bit naff - how about Git 101 for Lunar Developers or Sharing Git Repositories with Lunar Developers? Other ideas?
Some git basics are also described in Module Submission for developers.
Please feel free to add comments/corrections both here and there - engelsman
Creating a local copy of the central moonbase repository
Git convention requires user name and e-mail address to appear in commit messages, etc. Note that the first two commands set these for all your repositories.
satellite$ git config --global user.name "Full Name" satellite$ git config --global user.email "username@domain.name" satellite$ git clone git://lunar-linux.org/lunar/moonbase.git
If you are already a true Lunar developer, rather than an enthusiastic helper, you will need to do things slightly differently so that you can propagate your changes back to the central moonbase repository using your Lunar username and password [*]:
satellite$ git config --global user.name "Full Name" satellite$ git config --global user.email "username@lunar-linux.org" satellite$ git clone ssh://username@lunar-linux.org/var/git/lunar/moonbase.git
[*] Or is there a better way for setting the ssh username after the initial 'git clone git://...' ?
Tracking a Lunar developer's moonbase repository
Some developers have made their copies of their personal repositories, with branches, available at a central URL. [How?] If you wanted to access florin's repository, for example, you would first have to tell your own moonbase repository about it:
satellite$ cd moonbase.git satellite$ git add remote florin git://foo-projects.org/florin/moonbase.git satellite$ git fetch florin
Creating a local branch copy of a Lunar developer's branch
satellite$ cd moonbase.git satellite$ git branch -a # should show remote/*/* branches satellite$ git checkout -b florin remotes/florin/florin
If you look in .git/config you should now see:
- You have a new remote section pointing at florin's url;
- You have a new branch named florin that refer to refs/heads/florin.
Copying/updating files from a remote Lunar developer's branch
satellite$ cd moonbase.git satellite$ git checkout florin satellite$ git pull
Adding a new branch from a remote Lunar developer's repository
satellite$ cd moonbase,git satellite$ git checkout florin satellite$ git remote update florin satellite$ git branch -a # should now show new 'xyz' branch satellite$ git checkout -b florin_xyz remotes/florin/xyz
Using your moonbase.git with the lunar tools
You can configure the package management tools to work with your moonbase.git instead of /var/lib/lunar/moonbase by setting an environment variable:
satellite$ lunar set MOONBASE /path/to/moonbase.git
The package management tools can't auto-detect that you are using a moonbase.git, so if you want to work with your moonbase.git, you will need to change your working habits slightly:
- you need to run git pull in moonbase.git instead of lin moonbase to download a new version;
- lunar update won't work, so you need to run git pull ; lunar renew in moonbase.git;
- you shouldn't have a zlocal directory in moonbase.git, but you can have a zlocal branch instead
If at any point you need to go back to using the standard non-git moonbase, simply reset the environment variable:
satellite$ lunar set MOONBASE /var/lib/lunar/moonbase satellite$ lin moonbase
Depending on your workflow, or your level of expertise and confidence with git, you may find it easier or safer to maintain a hybrid system where you use moonbase.git to share test versions with other developers, but keep the standard "vanilla" moonbase. Don't forget that you can always restore a "vanilla" moonbase at any time by running lin moonbase. If you wait an hour, there might even be updated modules...