First Steps with Gitorious and git

Introduction

This page is intended for beginners with git and gitorious .

The documentation on how to write tests can be found in this page.

Hopefully this page will answer the remaining questions

Git

Probably all available options on git can be found with "man git". Specific help on an option ie "git fetch" can be found with "git fetch --help".

Lots of details on how git works and what it can and can not do can be found here. This books is available in various languages and can also be downloaded as PDF for offline viewing.

Getting started with github

First you need an account with github: https://github.com/join After registration you will receive an eMail to verify your eMail-Account.

Afterwards you can login to github

SSH-Keys

If you intend to use SSH with git, you have to register your public key with github. Go to "View profile and more", "SSH keys" and then "Add SSH key". Copy the content of your key (home-directory/.ssh/id_rsa.pub or home-directory/.ssh/id_dsa.pub) into the window and "Save".

Cloning t_functional

At https://github.com/CentOS/sig-core-t_functional you will find the button "Fork". Next you will be asked where to fork to, use your account. Klick "Clone repository" and you have your own copy of t_functional with an SSH-URL that looks something like this:

 git@github.com:<<username>>/sig-core-t_functional.git. 

The HTTPS URL looks something like this:

 https://github.com/<<username>>/sig-core-t_functional.git 

Installing git on your development box

To work with your copy, you have to create a local clone on your linux box. On CentOS-6/CentOS-7 "yum -y install git" should install everything you need to use git. For CentOS-5 the EPEL-repo has a similar package.

Cloning:

[user@host]$ git clone <<HTTPS-URL>> <<destination-dir>>

will create a clone of your github-repo on your local box. You will find your clone at <<destination-dir>>. You should set at least two global settings:

[user@host]$ git config --global user.name "your username"
[user@host]$ git config --global user.email "your email"

All git operations work best if executed within your <<destination-dir>> ("git clone" being an exception).

Within the destination-dir you will find the folder .git. Go there and edit the config-file. Change your user-credentials and add:

[remote "upstream"]
        url = git@github.com:<<username>>/sig-core-t_functional.git
        fetch = +refs/heads/*:refs/remotes/upstream/*

This allows you to update your clone from the t_functional-master in later steps.

Now to work with the test scripts :) Lots of good hints to start with can be found in this page and in the allready available scripts.

After you are satisfied with your work, it has to be commited. New files will have to be added to git with "git add <<path-to-file/filename>>". You can also use "git add <<path-to-file/*>>". A final "git commit --all" will open a vi-like editor. Please enter some comments regarding your changes. After exiting the vi your changes are commit. Use "git push" to push theses changes to gitorious.

Merge request

Your push (or pushes) to git need to be merged with the t_functional master. This is done on the web-interface. On the webpage of your clone - something like https://github.com/<<username>>/sig-core-t_functional - press the button "Pull requests" and then "New pull request". This will only work if there are differences between your clone and the master repo. Add some comments/notes, scroll down and select your commits up to the point you want to pull(you can keep the dropdown menues unchanged). "Create pull request" will do just what it says. On the next page you can see the diffs which you requested to merge. https://github.com/CentOS/sig-core-t_functional you will now find the number of "Pull requests" being increased by 1. Clicking on "Pull Requests" will show you all current and previous requests (possible states are Open, In Review and Closed).

Keeping in sync

With time your gitorious clone and your local copy will drift from the t_functional master (you work on your copy and others work on their copies/master, pushes/commits and pull request happen and so on). The best way to deal with this is to do a local merge of the current master and your local copy: "git fetch upstream" will fetch the current t_functional master from github. "git merge upstream/master" will now merge your local copy with the previously fetched master. This effectively writes all master changes to your local copy.

If you work on two different machines - assuming you commit your work after it is done - you can do something similar to keep your second machine in sync with your work and not always have to delete your local copy and do a "git clone ..." again: "git fetch origin" will fetch the current master of YOUR t_functional-clone from github (not the t_functional master). "git merge origin/master" will now update your local copy to the latest commit you pushed to github.

During these operations you will also see the "version" numbers of the various commits. i.e.:

[user@host t_functional]$ git fetch origin
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 9 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (9/9), done.
From github.org:<<USERNAME>>/sig-core-t_functional.git
   4a5d56d..33951fe  master     -> origin/master

The fetch operation downloaded the differences from 4a5d56d to 33951fe and put them in origin/master.

[user@host t_functional]$ git merge origin/master
Updating 4a5d56d..33951fe
Fast-forward
 tests/p_freeradius/0-install_freeradius.sh |    4 ++--
 tests/p_gcc/test_gcc.sh                    |   11 ++---------
 tests/p_php/10-php-test.sh                 |    3 +--
 3 files changed, 5 insertions(+), 13 deletions(-)

Now your local copy should match the data available online.

At the time of writing this wiki page 33951fe is also the latest version available on the t_functional - master so:

[user@host t_functional]$ git merge upstream/master
Already up-to-date.

There is no difference between the t_functional clone and the t_functional master so 'Already up-to-date' (as the last commit to master was the authors last commit to his clone and a subsequent merge request).

Who did what ?

If you are interested in specific details about a file you can issue

[user@host t_functional]$ git blame <<filename>>

This shows you in detail who edited what in the specified file and when this happend (time plus commit). An example:

[user@host t_functional]$ git blame AUTHORS 
^43deec8 Authors (Karanbir Singh      2011-05-05 16:37:36 +0100  1) Please add your name to this list with your first commit request
^43deec8 Authors (Karanbir Singh      2011-05-05 16:37:36 +0100  2) 
^43deec8 Authors (Karanbir Singh      2011-05-05 16:37:36 +0100  3) Karanbir Singh <kbsingh@karan.org>
9006252d Authors (Fabian Arrotin      2011-05-06 18:41:38 +0200  4) Fabian Arrotin <arrfab@centos.org>
0b5bb2db Authors (Karanbir Singh      2011-05-06 16:28:10 +0100  5) Athmane Madjoudj <athmanem@gmail.com>
14ae45e9 Authors (Karanbir Singh      2011-05-10 14:49:14 +0100  6) Steve Barnes <steve@echo.id.au>
28afdf9b AUTHORS (Johnny Hughes       2011-10-14 22:06:56 -0500  7) Johnny Hughes <johnny@centos.org>
dae1aa8b AUTHORS (Christoph Galuschka 2011-11-18 09:57:58 +0100  8) Christoph Galuschka <christoph.galuschka@chello.at>
7a1b1aae AUTHORS (Athmane Madjoudj    2011-12-09 19:06:00 +0100  9) Dan Trainor <dan.trainor@gmail.com>
48745f74 AUTHORS (Sahil Muthoo        2012-07-22 12:10:36 +0000 10) Nikhil Lanjewar <nikhil@lanjewar.com>
48745f74 AUTHORS (Sahil Muthoo        2012-07-22 12:10:36 +0000 11) Sahil Muthoo <sahilm@thoughtworks.com>
48745f74 AUTHORS (Sahil Muthoo        2012-07-22 12:10:36 +0000 12) Sahil Aggarwal <sahilagg@gmail.com>
48745f74 AUTHORS (Sahil Muthoo        2012-07-22 12:10:36 +0000 13) Saager Mhatre <saager.mhatre@gmail.com>


This page is created and maintained by ChristophGaluschka. Other Wiki contributors are invited to make corrections, additions, or modifications.

QaWiki/AutomatedTests/GettingStartedWithGitorious (last edited 2015-06-17 20:24:20 by ChristophGaluschka)