A Small Git CMSSW Tutorial

Introduction

This tutorial should give a small introduction to Git in the CMS environment. It is not complete or contains all available information. It is a summary of Giulio's tutorial. The aim is to explain how package are obtained using Git and how you track your custom changes of official code/packages in CMSSW_5_3_11.

Preparations

Obtaining GIT account and link it with CERN:

  • Frist you have to obtain a GIT account, see here.
  • In order to develop CMSSW you will need a GitHub account and to link it to your CERN account. This is easily done by going to CMS Topic Collector. Sign in with your CERN account -> Sign in with your recently obtained GIT account -> authorize app

Setup personal information

  • Login on lxplus/CERN
  • Run following commands:
    • git config --global user.name "First name Last name"
    • git config --global user.email <Your-Email-Address>
    • git config --global user.github <Your-Just-Created-GitHub-Account-Username>

Easy access of GitHub (optional)

  • If you have no ssh key: Follow generating-ssh-keys on GitHub to create a ssh key.
  • If you have already an ssh key: Login to GitHub -> settings -> SSH keys (https://github.com/settings/ssh) and add your key. I.e. copy paste the content of yourKey.pub
  • To use your key you have to execute following commands after each login:
    • eval $(ssh-agent); ssh-add /path/to/your/key
  • Test your configuration: ssh -T git@github.com
    • You should see: Hi XYZ! You've successfully authenticated, but GitHub does not provide shell access.

Checkout a CMSSW package

  • At the moment due to different CMSSW Git repositories a modified git-cms-addpkg is needed:
export PATH=~fhohle/public/gitCMSSW:$PATH
  • Setup a CMSSW environmet (using a SL 5 machine)
cmsrel CMSSW_5_3_11
cd CMSSW_5_3_11/src
cmsenv

  • Checkout a package, e.g. PhysicsTools/PatExamples
git cms-addpkg PhysicsTools/PatExamples
No release tags specified, using default CMSSW_5_3_11.
Release older than CMSSW_6_2_0_pre8, using cmssw-old.git instead of cmssw.git
You are on branch CMSSW_5_3_X
...
Branch from-CMSSW_5_3_11 set up to track remote branch CMSSW_5_3_X from official-cmssw.
Switched to a new branch 'from-CMSSW_5_3_11'
HEAD is now at cc0f159 CMSSW_5_3_11
  • Create your own development branch e.g. mydev
git checkout -b mydev
Switched to a new branch 'mydev'
  • Check which branches are available
git branch
  from-CMSSW_5_3_11
* mydev
  • Apply modifications
echo '#modfication' >> PhysicsTools/PatExamples/BuildFile.xml #this adds a line containing #modification at the end of BuildFile.xml
  • Check if modification is recognized
git status
# On branch mydev
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   PhysicsTools/PatExamples/BuildFile.xml
#
no changes added to commit (use "git add" and/or "git commit -a")
  • Add and commit your changes
git add PhysicsTools/PatExamples/BuildFile.xml
git commit -m "test message"
[mydev 6812826] test message
 1 files changed, 1 insertions(+), 0 deletions(-)
Your modifications were commited to your local git repository. * In order to push your new branch mydev to your piravte git repository at GitHub you should create it before. This is done by forking the official CMSSW repository: Visit https://github.com/cms-sw/cmssw/fork . After the forking is done you see you have a new repository cmssw, https://github.com/<your-username>/cmssw . Since we are using CMSSSW_5_3_11 which is in https://github.com/cms-sw/cmssw-old also fork this repository by clicking at the upper right fork button. Now you are able to push your new branch mydev to your GitHub account.
git push my-cmssw mydev
If obtain this message:
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
git wasn't able to find the my-cmssw repository in you GitHub account. Check if you forked the https://github.com/cms-sw/cmssw-old repository. If the push is successful you see:
Counting objects: 9, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 436 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
To git@github.com:fhoehle/cmssw-old.git
 * [new branch]      mydev -> mydev
You visit your account at GitHub and click on the branches drop-down menu you see your new branch mydev. Inspect the PhysicsTools folder and you see that PatExamples were changed recently with a message test message.

The tutorial ends here. It showed you are checkout done of specific packages and how you are able to save your local changes at your private GitHub account. Git has a lot more feature which help and support you in developing and keeping track of your code. These a out of scope of this tutorial, please visit github.com for more detailed information on branches, merging them, tags, ... . Thanks a lot to Giulio and his tutorials and talks. This small tutorial was a summary of material provided by him.

Additional Information

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2013-07-01 - FelixHoehle
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback