- Install gitolite:
sudo apt-get install git git-core python-setuptools gitolite
- Add the gitolite user (this is the user that will host the git repositories and control access):
sudo useradd gitolite
- As the user who will be administrating the set-up (i.e. someone OTHER than the gitolite user), create a set of ssh keys and move them to where the gitolite user can access them:
ssh-keygencp ~/.ssh/id_rsa.pub /tmp/admin.pub
- Switch to the gitolite user:
sudo su - gitolite
- Run the set-up command:
gl-setup /tmp/admin.pub
- As the user who will be administrating the set-up, clone the repository
git clone gitolite@[ip address]:gitolite-admin.git
This blog is a knowledge dump of all the technical information floating around in my head. It deals with anything involving software, hardware, gadgets, and technology.
Showing posts with label git. Show all posts
Showing posts with label git. Show all posts
Nov 4, 2013
Debian: Installing gitolite
Tried setting up gitolite in Debian following my earlier guide with CentOS, but it didn't work out as well because there were a few steps missing (Debian doesn't create the gitolite user automatically). These are the modified steps:
May 15, 2013
Git: Pulling a single directory only from a remote repository
I was working with a web application that used the Laravel framework and, because big projects take time, the framework was updated mid-project. I wanted to use these updates without messing up the changes I had already made to config files. So I came up with this workaround:
So in detail, I run the 'git checkout' command with the parameter 'laravel/master'. That parameter is a reference to the remote repository 'laravel' (which I had set up earlier by running 'git remote add laravel git://github.com/laravel/laravel.git') and specifically the 'master' branch. The '--' in the command means I want to check-out a specific file or directory, which in this case means the 'laravel/' directory.
Nice, short and sweet.
git checkout laravel/master -- laravel/
So in detail, I run the 'git checkout' command with the parameter 'laravel/master'. That parameter is a reference to the remote repository 'laravel' (which I had set up earlier by running 'git remote add laravel git://github.com/laravel/laravel.git') and specifically the 'master' branch. The '--' in the command means I want to check-out a specific file or directory, which in this case means the 'laravel/' directory.
Nice, short and sweet.
Dec 1, 2012
Migrating and transfering gitolite to a new server
I am going to assume you have already installed gitolite on two servers (if you haven't, check out my guide on installing gitolite). This post will outline how you will move your repositories from one server to your new one.
The server side
- You can edit some of the configuration files stored in the home directory of the gitolite user. You only have to do this step if you have an unusual set-up; it should work fine if you did a default install.
- Copy the contents of your repositories folder to the new server (except gitolite-admin; we will do this at a later stage). Use either the commands cp or scp. For instance:
scp -r repo.git/ root@192.168.0.1:/var/lib/gitolite/repositories/
- Change the owner and group of the copied repositories:
chown -R gitolite:gitolite repo.git/
- Clone the gitolite configuration repository on your administration machine:
git clone gitolite@192.168.0.1:gitolite-admin.git
- Add the keys and configuration files from your old repository and place them into your new repository. Do a commit and then a push:
git add .
git commit -as
git push - The server is now set up and ready to use! Optional: The guide quoted that you may need to run gl-setup again once the repositories have been copied across, but I didn't need to. You may want to do that step....
The client side
To point your git repository to the new server (so you don't have to reconfigure your IDE or scripts) just run the following commands:git remote rename origin old
git remote add origin git@192.168.0.1:repo.git
git remote -v
git remote rm old
Further Reading:
- Stackoverflow on transferring gitolite to another server
- Old official documentation on moving your gitolite server
Nov 30, 2012
Installing gitolite in CentOS 6
Gitolite is an management service that sits on top of git. It helps restrict users to certain projects (and what they can do on those projects). In this post we will install gitolite in a CentOS 6 environment.
- First we need to enable the EPEL repository. You could download and install gitolite directly, but I prefer to manage everything through the package manager for auditing purposes.
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -ivh ./epel-release-6-7.noarch.rpm - Install gitolite (it will most likely install a variety of dependencies):
yum install gitlolite
- If this is a brand new gitolite installation you will need to create a public SSH key on the account you will be using to administer your gitolite installation. The creation of these keys are outside the scope of this documentation. Once the key pair has been created, copy the public version to a common place where gitolite can access it (like temp). Use the command cp or scp to acheive this.
- Rename your copied public key with some sort of identifier. Gitolite uses the name of your keys to determine access.
- Log in as the gitolite user:
su - gitolite
- Initialize your gitolite service with the key:
gl-setup -q /tmp/user.pub
- Now you can use gitolite!
ssh gitolite@192.168.0.1 info
git clone gitolite@192.168.0.1:gitolite-admin.git
Further Reading:
- Quick 'n' Dirty start-up guide to gitolite
- Official documentation
Mar 10, 2012
Using GIT
GIT is a distributed version control system. Unlike SVN, which is centralised, each copy of a git project tree contains it's very own repository. This makes it easier to create branches and forks for development without polluting the main code trunk.
http://schacon.github.com/git/gittutorial.html
http://gitref.org
- To start your first local git repository:
- Initialise the repository
git init
- Add all the files in the current directory
git add .
- Commit your initial import
git commit
- Initialise the repository
- To monitor changes and logs in your code:
- View the revision history
git log
- View the file changes in the repository
git diff
- View the changes for a specific revision and file/directory path
git diff revision path
- Summary of the current changes to the repository
git status
- Some house cleaning functions:
- To add a file:
git add file
- To remove a file:
git rm file
- To move a file:
git mv file
- To remove all untracked files (such as temporary files used during compilation):
git clean
- Configure your git instance
- Change your username
git config --global user.name "Your Name"
- Change your email
git config --global user.email email@domain.com
- Common functions
- Clone an existing repository
git clone url
- Fetch the changes from remote master repository
git fetch
- Similar to above, but this command will merge the changes as well
git pull
- Push your changes to a remote repository
git push url
- Commit all your changes to the local repository
git commit -a
- Edit your last commit with latest changes
git commit --append
- Toss away your last commit
git reset HEAD^
- Assign blame for problematic files
git blame file
- Tags and branches
- Tags a version
git tag -a name
- List tags
git tag -l
- Show the details about a tag
git show tag
- Create a new branch
git branch branch
- Switch to a branch
git checkout branch
- Delete a branch
git branch -d branch
- List all branches
git branch
- Merges a branch to our current working branch
git merge branch
http://schacon.github.com/git/gittutorial.html
http://gitref.org
Subscribe to:
Posts (Atom)