Your web-browser is very outdated, and as such, this website may not display properly. Please consider upgrading to a modern, faster and more secure browser. Click here to do so.
I’m currently setting up a new dev server at work. This includes hands-on work such as writing PHP organized in namespaces, but at a more technical level, modifying lighttpd and installing lots of packages on a Ubuntu server.
The dev server which is being deprecated is equipped with svn & trac, which has been really nice, especially for browsing the source code, code reviews and managing tickets, so the goals are set for this new server.
Gitweb will correspond to the demands for viewing source code, diffs and branches. Installing it and getting it up on lighttpd was a breeze, thanks to the guide How to setup gitweb with lighttpd on Ubuntu - jonathanrobson.me.
I used his config with some tweaks. The
$projectroot variable in /etc/gitweb.conf now points at a directory which has a clone of each of our reposes. I.e.
$ cd /home/git/projects
if /home/git/projects/ is where you store all of your repositories, in a common place as a base for your dev or stage area. Read my entry Using git init —bare for a slim repository look for a directory layout that works.
If you followed my approach,
$ ls /home/git/projects
should only consist of directories called
project-2.git and so forth. This is ideal for gitweb, which prefers to have a single directory to check for git repositories. (Check jonathanrobson’s link above for the whole shebang.)
There’s a github repository on https://github.com/kogakure/gitweb-theme which has an easily installed theme that looks much better than the original bundled with gitweb.
Until now, I’ve mainly worked alone with my git repositories. Sometime pushing to my github-account, but always using the service as a kind of backup solution. Until now. At work, we’re setting up our new environment with git and I’m lucky enough to learn it while doing it.
This setting will differ quite a lot from what I’m used to:
Also, exercising a plain
git init routine creates a complete repository with all source files, branches & stuff; which really are ment to keep track off and develop in. Let’s not, let’s just keep the repository there and only
git push there so all development will be done in each user’s local repository.
Let’s get to the good stuff:
# create a user named 'git' and make that user the owner of your repositories, and nothing else $ mkdir -p /home/git/repositories $ cd /home/git/repositories $ mkdir your-project.git && cd your-project.git $ git init --bare $ git config receive.denyCurrentBranch "ignore" $ mkdir -p ~/www/your-project && cd ~/www/your-project $ echo "lalala, random file" > random.txt && git add . && git commit -m "First commit" $ git remote add origin /home/git/repositories/your-project.git $ git push origin master
There you go, a fully capable external repository, local on your dev machine, ready to export to a staging/testing/Q&A-setting. For an easy setup of this, go read Using Git to manage a web site which worked out of the box for us.
If you get any errors whilst doing this, google it or just try to parse it (for us, it mostly came down to
chmod-ing the -R /home/git/repositories/ folders, so using
sudo helps a lot).
Ok, just noticed that a forked repository of mine wasn’t actually automatically updated by Github. Luckily enough, http://help.github.com/forking/ made the process pretty painless:
git clone my-repo-with-read+write-rights git remote add upstream original-repo-url git fetch upstream git merge upstream/master git push origin master
Next time I’ll just repeat
git fetch upstream git merge upstream/master git push origin master