Current revision: 0.7
Last update: 2020-06-24 20:47:52 +0000 UTC
I am the wisest man alive, for I know one thing, and that is that I know nothing.
Plato , The Republic - 380 B.C.
I’ve been looking at Google for some quick howto’s on how to setup a git repository on my home server. I’ve lost a couple of minutes reading the howto’s on-line and then a couple of hours trying to figure out what I was doing wrong. The entire process is plain simple and takes less then 1 minute if you know how git works. Most people who write the howto’s, probably don’t, because they don’t work. For instance, you can’t push/pull an empty repository with git. It complaints and comes out with an error. Then if you Google on the error you find any kind of possible blog post and forum post and you end up losing… time.
I assume that you use ssh + keys for your server. If you don’t use ssh, you’re on your own. Google on how to create and use ssh keys and come back if you don’t know how to create rsa keys.
We will create the remote repository first.
$ mkdir -p Projects/myeliteproject.git && cd Projects/myeliteproject.git $ git init --bare $ exit
We need the “–bare” flag. If you want to know why, read the manual and have in mind that this is a remote repository.
At this point we go on the desktop computer where the actual development will take place. I assume that you will use the same directory and project for the sake of coherence.
$ mkdir -p Projects/myeliteproject.git && cd Projects/myeliteproject.git $ git init $ git remote add origin ssh://[user]@[hostname]/full/path/to/the/repo.git $ git push origin master $ echo "We need this commit in order to avoid errors" > first_commit.txt $ git add first_commit.txt $ git commit (write a reason here... "first needed commit" is a good one) $ git push $ git config branch.master.merge 'refs/heads/master' $ git config branch.master.remote origin $ git config --global push.default current (<em>This config is to avoid warning messages. Please read <a href="http://progit.org/book/ch9-5.html">here</a> and consult documentation for refspecs</em>) $ git pull Already up-to-date.
You should be able to see the “Already up-to-date” flag also. Now on how to proceed from here, read the git tutorial. Apart from gitweb there several others solutions for viewing your repository online. The php-ones are the most easy to install and configure.
PHP Support for HTTP View of the Branch
Gitview is a simple php script that can take advance of Geshi, for syntax highlighting. Now if you just setup gitview it will use geshi, which must be manually installed and used. No big deal, just download geshi adjust the path in the config.php:
// Whether to use GeSHi for source highlighting $conf['geshi'] = true; // Path to geshi.php $conf['geshi_path'] = '/path/to/geshi.php'; // depends on where you put this...
Then you just adjust the “index.php” file to use the specific language by changing this line:
$lang = Geshi::get_language_name_from_extension($ext);
$lang = "objc";
Note that this is for Objective-C but Geshi supports an awful lot of languages. The problem with geshi is that it can’t understand _on the fly _which programming language you want to use, according to the developers the reason for this is:
[...] 00:41 < atmosx> It's easy for languages like perl, python, bash or ruby but how can you tell if an .m extension is C++ or Objective-C? :-) 00:54 < BenBE2> atmosx That's the problem with the current approach: It doesn't even look at the content and thus gives the first language it finds for a language. 00:54 < BenBE2> New approaches will look at the actual content or try other means to get around this. [...]
Got them on Freenode. Mr BenBE gave me the correct syntax to put into that index.php file to make it work as it should. Thanks for the support!
You can find the development team of Geshi at Freenode channel “#Geshi”.
That’s all! :-)
If you get this kind of error:
<code>warning: You did not specify any refspecs to push, and the current remote warning: has not configured any push refspecs. The default action in this warning: case is to push all matching refspecs, that is, all branches warning: that exist both locally and remotely will be updated. This may warning: not necessarily be what you want to happen. warning: warning: You can specify what action you want to take in this case, and warning: avoid seeing this message again, by configuring 'push.default' to: warning: 'nothing' : Do not push anything warning: 'matching' : Push all matching branches (default) warning: 'tracking' : Push the current branch to whatever it is tracking warning: 'current' : Push the current branch</code>
Take a look here. Don’t panic it’s just a design “flaw” from overzealous developers!
For a more detailed howto with RoR support take a look here.