Development Server

From IridiaWiki
Revision as of 14:01, 16 January 2013 by Mascia (talk | contribs)
Jump to navigationJump to search

IRIDIA has a development server called "iridia-dev". The server provides the following services:

  • subversion repositories
  • git repositories
  • 'trac' environments for projects (wiki, bugtracker etc)
  • webpages for projects

So if you have some software you would like to make open source, you can host this on the new server.

How to add a new subversion/git repository?

Currently, you have to contact the server administrator for that. See Lab responsibilities to find out who's the current administrator of the server and the repositories.

How to access the subversion/git repositories?

You should get a username and a password from the repositories administrator. Instead of accessing the server by ssh, you have to use https. The repository URL is the following:

 https://iridia-dev.ulb.ac.be/projects/%NAME%/{svn%7Cgit}

For example, you can check out a project like this:

 svn co https://%USERNAME%@iridia-dev.ulb.ac.be/projects/%REPNAME%/svn

I want to delete/archive old repositories

Old repositories are stored in iridiadevserver@fallopius:~/archived_svn_repos

Ask the administrator to move it there (ssh fallopius-backup from iridia-dev as root).

Contact the administrator if you have any problems/questions.

Quick Git HowTo

No password [Linux]

If you don't want to be prompted for your password at each operation you have to add in your home directory a .netrc file:

   cat > ~/.netrc
   machine iridia-dev.ulb.ac.be
   login %YOUR_USERNAME%
   password %YOUR_PASSWORD%
   CTRL+D

and change permissions, so that you are the only one that can access it

   chmod 600 ~/.netrc

Note that if you clone a repository specifying your username in the URL (e.g., https://%USERNAME%@iridia.dev...) your .netrc file will be ignored and you'll have to specify also the password in the URL. If you don't like the idea of your password being stored in clear check out this Ubuntu page about how to store your password in your keyring. If you still want the password to be asked every time and in a remote connection you want to type the password in the command line and not a pop-up window, set in your bash profile:

   unset SSH_ASKPASS

No password [Os X]

On Os X, after asking your password the first time, it will be stored in your keychain:

   curl http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain -o git-credential-osxkeychain
   sudo mkdir -p /usr/local/bin
   sudo mv git-credential-osxkeychain /usr/local/bin
   sudo chmod u+x /usr/local/bin/git-credential-osxkeychain
   git config --global credential.helper osxkeychain

Configuring Git

Then you have to add some information about yourself in the configuration:

   git config --global user.name "Pinco Pallino"
   git config --global user.email "ppallino@iridia.ulb.ac.be"
   git config --global --add color.ui true

this will be default in git 2.0

   git config --global push.default simple

this is already default, but you could change it with your preferred editor

   git config --global core.editor 'vim'

to wrap lines in git diff

   git config --global core.pager 'less -r'

Iridia certificate

Don't ignore the certificate verification

   # git config --global http.sslverify "false"

don't do it. Instead, open the page of your git repository in Firefox (this has to be done just for the first repository), when you are prompted for adding an exception for the certificate, ask Firefox to show you the certificate and export it as a X.509 (PEM) without chain or other options and save it in a file like iridia-dev.ulb.ac.be.pem. Then add it as a sslCAInfo:

   git config --global http.sslCAInfo /home/%YOUR_USERNAME%/iridia-dev.ulb.ac.be.pem

Other useful stuff

All the configuration options specified above go into a configuration file in your home directory, i.e., ~/.gitconfig. You can add further options manually directly in that file or with git config command line. For example I shamelessly copied these useful aliases from here:

   [alias]
       # list commits in short form, with colors and branch/tag annotations
       ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
       # list commits showing changed files is invoked
       ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
       # list with no colors if you need to chain the out put with Unix pipes
       lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
       # list oneline commits showing dates (git lds -10)
       lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
       # list oneline commits showing relative dates (git ld -10)
       ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
       # default look for short git log
       le = log --oneline --decorate
       # all the commits related to a file, with the diff of the changes
       filelog = log -u
       fl = log -u
       # show modified files in last commit
       dl = "!git ll -1"
       # show a diff last commit
       dlc = diff --cached HEAD^
       # content of commit (full diff) given revision (got ls -10; git dr 8cf2224)
       dr  = "!f() { git diff "$1"^.."$1"; }; f"
       lc  = "!f() { git ll "$1"^.."$1"; }; f"
       diffr  = "!f() { git diff "$1"^.."$1"; }; f"
       # find a file path in codebase (git f README.txt)
       f = "!git ls-files | grep -i"
       # search/grep your entire codebase for a string
       grep = grep -Ii
       gr = grep -Ii
       # grep from root folder
       gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f"
       # list all aliases
       la = "!git config -l | grep alias | cut -c 7-"
       # show the last tag
       lasttag = describe --tags --abbrev=0
       lt = describe --tags --abbrev=0
       # basic shortcuts
       cp = cherry-pick
       st = status -s
       cl = clone
       ci = commit
       co = checkout
       br = branch
       diff = diff --word-diff
       dc = diff --cached

and I also added a global gitignore file:

   git config --global core.excludesfile ~/.gitignore_global

containing some generic patterns for Linux and some specific ones for Os X:

   cat > ~/.gitignore_global
   .DS_Store
   .DS_Store?
   ._*
   .Spotlight-V100
   .Trashes
   Icon?
   ehthumbs.db
   Thumbs.db
   *~
   *.lock
   *.DS_Store
   *.swp
   *.out

Cloning your repository in a local directory

At this point with everything configured you should be ready to clone a repository

   git clone https://iridia-dev.ulb.ac.be/projects/%REPNAME%/git %REPNAME%

if you are on Linux and you have configured your .netrc you should have no issues, otherwhise you have maybe to specify also your username:

   git clone https://%YOUR_USERNAME%@iridia-dev.ulb.ac.be/projects/%REPNAME%/git %REPNAME%

and you will be prompted for a password. If you later decide to use a .netrc file, you have to remove your username from the reopository url:

   cd %REPNAME%
   git remote set-url origin https://iridia-dev.ulb.ac.be/projects/%REPNAME%/git

On Os X, regardless of the username in the URL, if you installed the keychain helper, after typing the password the first time, you will not be prompted anymore.

Using Git for SVN users

You should definitely read this short introduction and if you really want to understand what you are doing you should read this slightly longer introduction. ;)

Anyway if you want a blind correspondence of basic SVN commands here it is:

   svn commit => git commit -a

this is actually a local commit, to push it to the repository you need to make:

   git push origin --all

or simply

   git push

for updating your local copy to the most up-to-date version on the repository

   svn update => git pull

changing your mind about your last commit message before pushing it on the repository

   git commit --amend -m 'Edited message.'

The other commands like git diff are very similar to the corresponding svn ones. Branching and tagging are of course different, but you know it already if you are planning to use git.

Anyway, this short list is here to help you if you need to quickly commit something and you are not planning to use Git for your project. On the contrary, if you want to understand why there is a '-a' after the git command, what is the staging area, how to cherry pick a commit on a branch, or how to change the history of the commits on the repository, read at least the short introduction.