Git instructions

From Gw-qcd-wiki
Jump to: navigation, search

Obtaining and Installing Git

  1. Go to http://git-scm.com/ and download the most recent tar ball.
  2. untar the tarball and cd into the git directory
  3. Set the install directory by running:
    ./configure --prefix=install_directory
  4. run the command:
    make -j && make -j install
  5. add (if necessary) install_directory/bin to $PATH and refresh your shell and your done.

Checking Out a Repository

In order to checkout a repository you have to first be granted access. You can ask for access by contacting an administrator. If granted access you will have to present an ssh public key as well as setup an account on Samurai where the git repositories are hosted. Current administrators are

  1. Andrei Alexandru aalexan@gwu.edu

Once you have access you can pull a repository using
git clone gitosis@samurai.phys.gwu.edu:repos_name

In the last step you will be prompted for your password on Samurai unless you have added the local host's pub key to your authorized keys on Samurai. The current repositories available are

  1. gwu-qcd This repository contains the current suite of programs available to perform lattice QCD calculations.
  2. thrust This repository contains the git thrust mirror. Thrust is an efficient c++ library which is used for example by gwu-qcd.
  3. mem-prof This contains a memory profiler program that allows one to determine how much memory (cpu and gpu) is being used by a program.
  4. nhyp This contains the codes from Anna Hassenfratz and company which generate the nhyp-smeared-clover improved dynamical fermions.
  5. milc-double This contains Andrei's hybrid milc-code.

Adding a Repository

The following describes how to add a git repository. You must have write access to the gitosis-admin directory in order to add repositories.

  1. Start by entering the gitosis_admin directory and pulling the latest copy using
    git pull
  2. open gitosis.conf with your favorite editor and add the following three lines

    [repo repository_name]
    description = repository description
    owner = owners_name

    You can use the repositories already listed in gitosis.conf as a an example.
  3. At this point, it is necessary to give write permissions to the repos. You have to at least give write permission to the location which you will make the initial push to master i.e. the location you are currently working in. If you want to give all qcd users the ability to pull simply add the name of your repo to the list of repos that are writable for the qcd group. You can do this by updating the gitosis.conf file. For example

    [group qcd]
    writable = repo_name1 repo_name2
    memebers = key1 key2 .. etc


    If you want to define a new group of users that can access the repos then add a new group by adding the three lines

    [group group_name]
    writable = my_repos_name
    members = member keys

    Note: see the section on adding keys to add member keys properly.
  4. Finally, push the changes using:
    git commit -a
    git push
  5. Next we have to push the repository to the host i.e. gitosis. To do this first initialize your working directory (the directory you want to add as a repository) by executing the command
    git init

    Then add all the files in the directory by using (if you don't want to add all files then just use git add to add the files you want)
    git add .

    Then commit the changes using
    git commit -a
  6. Next add the URL for Samurai by executing
    git remote add origin gitosis@samurai.phys.gwu.edu:repo_name.git
  7. Then push your changes using
    git push origin master
    and you are all done! Make sure to test the functionality of the new repos by doing a test clone i.e.
    git clone gitosis@samurai.phys.gwu.edu:repo_name.git


Adding Keys to gitosis.conf

FAQ by Administrators

How do I fix gitosis.conf if I accidentally pushed an update that contains a typo?

Unfortunately pushing a change to gitosis.conf which contains a typo also renders you unable to push or pull. As a result, you can't fix the typo simply by editing, committing, and pushing. The solution is to edit the file manually as the git user on Samurai. To do this you need to edit the gitosis.conf file owned by the git user. It is locate on samurai at
/srv/gitosis/gitosis-admin
simply fix your typo and save the changes.

Using tags

The idea behind tags is simple --- you just associated with a certain commit a tag. In the following, I will describe how to use tags to create revisions. You can tag a commit by issuing the following command
git tag <name_of_tag> <name_of_commit>
The name of the tag can be whatever you like and the name of the commit is that long hexadecimal number which you can find using git log. If no commit is specified the most recent commit is used. After issuing this you can push the changes using
git push --tags
and tags can be deleted using
git tag -d <name_of_tag>
To see what the tags have been made you can look in .git/refs/tags. There will be a list of files whose names are the names of the tags and which contain the commit they point to. As an example, I will explain how I created the gwu-qcd-v1.0. First, I create a tag of the commit I want to represent version 1.0 using the aforementioned commands.
git tag gwu-qcd-v1.0
git push --tags
To revert to this version I simple use
git reset --hard gwu-qcd-v1.0
which will reset the current head to the commit that gwu-qcd-v1.0 points to. NOTE: --hard removes any changes so you will lose any changes to the working directory. If you don't want this use --soft.

FAQ by Users

Git Tutorials

  1. gittutorial(7) can also be found online, http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
  2. http://www.kernel.org/pub/software/scm/git/docs/everyday.html
  3. http://git-scm.com/documentation