Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Friday, 1 March 2013

Installing Git and Virtualenv on Linux or Mac

For Debian/Ubuntu Linux:

sudo apt-get install git python-setuptools

For Redhat/Fedora Linux:

sudo yum install git python-setuptools

For Mac:

Install MacPorts and then:
sudo port install git python-setuptools

Continuing on for all of the above

sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper

Now, you may want to set some defaults in your ~/.bashrc. My relevant entries look like this:



export WORKON_HOME=$HOME/Projects
export VIRTUALENVWRAPPER_HOOK_DIR=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_LOG_DIR=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

git config --global user.name "Terse Col"
git config --global user.email myemail@gmail.com
git config --global http.sslVerify false

Now away you go:

mkdir $HOME/.virtualenvs
source $HOME/.bashrc
mkvirtualenv mynewproject 
cdvirtualenv

Saturday, 25 June 2011

Set Up Your Own Git Repository Hosting Service in Three Minutes

You might have seen my earlier post "A Review of Free Code Repositories".

Well I forgot about hosting your own. Really handy for hobbyist development. I have one of those free developer servers from Amazon out there somewhere. I don't use it much except to demo the occasional site and so on.

I decided that it was a good idea to set it up as a git repository and i show you here how to do this. If you are using something Ubuntu-ish remotely then this should take about three minutes.

A Word of Explanation
This is the simple setup, it avoids creating 'git' user on the remote server, but you DO need to use a seperate key for using the git service and I show you that first.

On your local machine:

# echo "Host gitserver
  Hostname ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
  User git-col
  PreferredAuthentications publickey
  IdentityFile ~/keys/git-col.pub
" >> ~/.ssh/config

# mkdir ~/keys
# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/col/.ssh/id_rsa): git-col.pub # do NOT accept the default
# cp git-col* ~/keys
# scp git-col.pub ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com:
# ssh 
ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com

On your remote host you are now logged in as 'ubuntu':

# sudo apt-get install git
# git clone git://github.com/sitaramc/gitolite
# ./gitolite/src/gl-system-install 
# gl-setup -q ~/git-col.pub 
# exit

On your local machine:

# git config --global user.name "Your Name"
# git config --global user.email your@email.address
# git clone gitserver:gitolite-admin
# exit

That's it really. To create a new repository called dummy and initialize it, you can do something like this.

On your local machine:

# set the new repository name
export repo=dummy

# update the gitolite conf file with your new repository
cd ~/gitolite-admin
echo "        repo    ${repo}" >> conf/gitolite.conf
echo "                RW+     =   @all" >> conf/gitolite.conf

# push the config to your server
git commit -m "added new repository ${repo}" conf/gitolite.conf
git push 

# make sure you cd to an existing directory!
mkdir ~/Projects
cd ~/Projects

# pull back the new empty repository
git clone gitserver:${repo}

# go to repository and make any change
cd ${repo}
echo "*.pyc" >> .git/info/exclude # I use python
touch README

# do your first push back to master
git add .
git commit -am "repository ${repo} pushed to origin on gitserver"
git push origin master

You'll be using that last code section again, so you might want to make it into a script.

Never type anything you don't understand. 

If I've made any mistakes then please let me know.

Monday, 6 June 2011

Install Git, Pip and VirtualEnv and VirtualEnvWrapper on Ubuntu in a Minute

From a terminal, type:

sudo apt-get install git python-setuptools
sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper

Now, you may want to set some defaults in your ~/.bashrc. My relevant entries look like this:

export WORKON_HOME=$HOME/Projects
export VIRTUALENVWRAPPER_HOOK_DIR=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_LOG_DIR=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --distribute'
source /usr/local/bin/virtualenvwrapper.sh

git config --global user.name "Terse Col"
git config --global user.email myemail@gmail.com
git config --global http.sslVerify false

Now away you go:

mkdir $HOME/.virtualenvs
source $HOME/.bashrc
mkvirtualenv mynewproject 
cdvirtualenv

Wednesday, 1 June 2011

A Review of Free Code Repositories

In this article, I’m going to assume you are part of a *One Sized Team*, because there are loads of alternatives and I’m trying to keep the word count at a reasonable level. If you don’t fit that outline then you can still read on because most of the available offerings also have options that might well be right for you, but at a small monthly cost. I cover these in my article on *Code Repositories for Fun Sized Teams*.

Where to store your code?
So you've got some code and you need somewhere to put it so that it won't get lost when someone steals your laptop.

Well there are options:

  • Copy it to a USB drive
  • Upload the folder to Google Docs
  • Email it to yourself
  • Paste it into Pastebin

Well I know that I have done of all of these things at times and that’s just fine for snippets of code. With bigger bits of code you’ll need something a bit cleverer. Something that let’s you keep track of changes. A Code Repository.

Assembla
Assembla offers one free private Git or Subversion repository (which they call a space) although you have to find it because they'd rather you took a paid for option. You can find the free offerings at https://www.assembla.com/free. You are allowed as many public spaces as you want. The Git  implementation uses Git over ssh.

Also be aware that they automatically throw in the free trial additions which is fair enough, but you can drop these extras immediately if want and just get used to the free set of tools which include you're storage space and a ticketing system.

They also provide nice clear instructions on how to get going with setting up your repository, although putting your stuff under 'start' in their menu system confused me because I expected it to be under 'Home' or 'Your spaces' or something similar.

Berlios
Berlios offer Git and Subversion hosting (and other tools) for proper grown up Open Source projects. Too much hassle for me, which is probably their plan. Looks much like SourceForge. Have a read at the Wikipedia entry.

Bettercodes
Bettercodes is rather cool for a number of reasons. Firstly, they allow you multiple projects each with it's own Subversion or Git (Smart HTTP) repository. You can either make your code public, private of hidden and also invite others to work on your projects. You also get milestones and tasks and flat file storage. One word of caution; this site is in beta and although the repository stuff worked fine, there are definitely some teething problems. There's no word yet of a pricing plan, so get on there and give them some feedback.

Bitbucket
Bitbucket offers multiple, free, private project repositories with wikis and issue tracking. It's easy to use and reassuringly swish.

My only issue is that it only offers Mercurial repositories and I much prefer Git. That being said, let me just repeat. Bitbcket offers multiple, free, private project repositories with wikis and issue tracking."

Codeplex
Codeplex is Microsoft's version of proper grown up Open Source projects. Free for Open Source stuff and uses Mercurial or Subversion. Again, like Berlios,too much hassle for me.

Fedora Hosted
"Fedora Hosted is a project sponsored by the Fedora Project to allow upstream developers to host their code and collaborate online." See Berlios, Codeplex and grown ups. Not for me at this stage.

GitHub
GitHub is the most famous Git repository out there. Free plans are all public so other people will be able to see your code, but the interface, instructions etc are lovely and there's a nice repository explorer. Only Git (over ssh) is available.

Gitorious
Again, like GitHub, Gitorious is an attractive and easy to use site. Repositories are required to be under an open source licence (not just public) which may or may not suit your purposes. Only Git (over ssh) is available.

GNU Savannah
Savannah is another site for grown ups. This time focusing on free software projects (hence GNU). The rules here are particularly strictly enforced and you aren't even allowed to utilize non-free formats in your code. They provide repositories in CVS, GNU arch, Subversion, Git, Mercurial, Bazaar which is quite astonishing and there are loads of extra tools such as mailing lists and bug tracking etc. Looks like SourceForge. Don't get me wrong, this is a mighty site, but it doesn't suit everybody's requirements.

Is your's an Open Source Project?
Google Code
The sheer number of Google tools that integrate into this site must make it tempting for anyone. It's really useful, but as obvious as the advantages are, I'm going to mention a couple negative points here, but please take them in the context of an excellent site.

Firstly it only offers Mercurial and Subversion code repositories. These are perfectly good, but I still prefer Git.

Secondly projects have to be Open Source. This is not so different from lots of other sites mentioned here, but since Google offers almost all it's tools freely, including Gigs of space for email, sites, docs etc, I don't really understand why they don't offer a few megabytes for private code repositories. Any Google guys out there?

JavaForge
JavaForge looks excellent and the number of tools is impressive (" Web hosting, Document Management, Wiki, Forum, Online chat, Issue tracking integrated with optional Git, Mercurial or Subversion revision control"), but in short I don't do Java as a hobby and this is definitely a Java site. The Open Source rule applies. Java for grown ups.

LaunchPad
I haven't used LaunchPad, but it looks really rather useful. Firstly it's only for Open Source projects (for which it is free), and secondly it uses Bazaar as it's version control system. If you can work with those then I think you should have a good hard look at this offering as it offers stuff like Bug Tracking, Mailing Lists, Teams, FAQs, Code Review and more.

ProjectKenai
ProjectKenai is now owned by Oracle and is being closed/shifted/shut down.

SourceForge
The daddy of them all, SourceForge has some great statistics. I looked just now and it claims to be hosting 294,229 projects and had 3.8 million downloads today. If you don't mind people downloading your code for free or with an Open Source license, you can host it here. It offers all the version control systems already mentioned (and good old CVS) and gives you room for WIKI, files and other niceties.

Surely there's some kudos in just having a SourceForge Project. You could print your own t-shirts!

Anyway, don't forget about SourceForge, there's a reason the other grown up sites tend to emulate it.

Finally

Have I missed anything? Please ley me know.

There's some other information on wikipedia:

Tuesday, 31 May 2011

What a Smart Git

This article is a primer on Git protocols so that you get to grips with what specific Git repository providers are offering. I'll cover Code Repositories in a follow up article.

Traditionally Git lets you communicate with the Git Server (Repository) via four protocols:

  • Local (file system)
  • Secure Shell (SSH)
  • Git
  • Dumb HTTP
Local is probably little used because after all what's the point of having a repository for your code  on your hard disk if you're hard disk crashes, or your laptop gets stolen.

SSH and Git protocols worked just fine because they could talk to the server and get things done efficiently.

Dumb HTTP was a bit of a bodge because it could not be used to talk to the server and things were very inefficient (see the references below).

So, What's The Problem?

Firewalls, especially in the workplace, just hate it when people try to use anything except the standard ports. You know, HTTP, HTTPS, SMTP and after that they get sulky. Maybe, you'll be allowed to use FTP, but certainly not port 9418 (Git) or 22 (SSH).

Smart HTTP

The Smart HTTP protocol is really still just HTTP, but it's the server side that got smarter. Since Git version 1.6.6, Git servers can communicate with the client in a much smarter way using HTTP which makes it just as efficient as SSH or Git protocols AND allowing us to use Git anywhere we can browse the Internet; so long as the repository provider has things set up to use Smart HTTP.

If they aren't now, they soon will be.

References: