Learning

Missing definitions

  • index
  • (working) tree
  • repository
  • branch vs fork

What I have to read

What I have to learn to do

  • Develop a package in a branch of mine and then propagate the changes in the same package in another branch of mine
    • is that affected by the way the package has been committed into the two branches? Does it require a proper history?
    • write a description of this workflow to get help
  • Does my fork need to be updated from time to time?
  • How to maintain the same package in different branches easily
    • case 1: the package is and it will be identical in the two branches
    • the package differs between the two branches but some changes can be applied to both
  • Learn how to profit of git clone, git fetch
  • learn what git cms-merge-topic does
  • learn what git add submodule does

Setup

How to ignore some file types

From here: https://help.github.com/articles/ignoring-files
  • create the file .gitignore_global in the home directory in lxplus
  • add the line *.pyc
  • run the command git config --global core.excludesfile ~/.gitignore_global

Workflows

How to check what is the status of the working area

  • git status

How to check what is the status of the remote repositories

  • git remote

My configuration

  • git config --list

Remote repository name syntax

If you don't want to have trouble with Error 403 try to use the ssh syntax for the remote repository: git@github.com:venturia/TrackingPFGWebInterface. It should work if you have the public key set properly.

How to get just one file from another branch (a.T.)

According to this page it is enough to do: git checkout <branch-name> -- <file-name>

How to create a new branch in my own repository from a branch in the original repository (a.T.)

Create a CMSSW working area and then:
git clone -b CMSSW_7_1_X -n git@github.com:cms-sw/cmssw.git $CMSSW_BASE/src
git remote add my-cmssw http://github.com/venturia/cmssw
git push my-cmssw CMSSW_7_1_X

How to modify some pieces of code in a personal branch and push it back

Option 1 (a.T.)

git init
git remote add my-cmssw http://github.com/venturia/cmssw
git config core.sparsecheckout true
echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
echo Validation/RecoVertex > > .git/info/sparse-checkout
git pull my-cmssw my-62x (or git pull https://github.com/venturia/cmssw CMSSW_5_3_X)
git checkout -b <new-branch-name>

If you want to syncronize with the latest development in CMSSW:

git fetch git fetch https://github.com/cms-sw/cmssw CMSSW_5_3_X
git merge FETCH_HEAD

Then the code is modified and committed. To do so it can be useful to fetch other branches in other repositories and cherry-pick other commits Finally (I am not sure about what follows)

git push my-cmssw [HEAD:]my-62x

Option 2

Start with a clone of the branch whose code I want to modify. In this way sparse checkout will not work according to this page

How to prepare a working area with a branch to the personal cmssw repository

So far I managed to achieve that in this way:

Then set the sparse checkout and then

  • git checkout

In this way there will be the full tree with all the branches as remote branches and only one local branch, <branch-name> which will be the HEAD. The remote branches can be recreated from the remote ones with a command like =git branch <branch-name> origin/<branch-name>

How to create a new branch identical to another one

Starting from a working area which contains the old branch:
git checkout -b <new-branch-name>
git push my-cmssw <new-branch-name>
Done!

How to put UserCode area in a personal cmssw repository

  • go in the working area already prepared with a branch to the personal cmssw repository (but I have not yet tried with the procedure above and, instead, I have profited of a working area "magically" setup with git-cms-addpkg ...)
  • be sure that the active branch is the correct one
  • checkout from CVS the UserCode files
  • delete the CVS directories with something like rm -rf CVS , = rm -rf */CVS=, rm -rf */*/CVS , ...
  • run git add <name-of-usercode-directory>/*
  • git commit -m "sensible comment" <name-of-usercode-directory>
  • git push my-cmssw <branch-name>

Attempt to get some packages from a repository

Inspired by http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/
  • created a CMSSW working area
  • cd CMSSW_4_4_5_patch3/src
  • git init
  • git remote add my-cmssw http://github.com/venturia/cmssw
  • git config core.sparsecheckout true
  • echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
  • git pull my-cmssw my-44x

How to move some newly created/developed packages from one branch to another

Option 1

The following instructions look too much complex to be the right way to achieve this task. But for the moment this is what I got
  • Create the CMSSW working are (if needed)
cmsrel CMSSW_5_3_11
cd CMSSW_5_3_11/src
cd src
  • Clone without any real copy of the files the personal branch where the new packages hav to be put
git clone -n -b my-53x -o my-cmssw git@github.com:venturia/cmssw.git $CMSSW_BASE/src
  • Checkout at least one package from the branch. This is really ugly but without that the next git commit command will attempt to delete all the files from the branch since none are found in the working area (at least this is my take...)
git config core.sparsecheckout true
echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
git checkout
  • download from the other branch the packages to be added to the current branch. If I do a git checkout from the other branch using the sparse checkout and the syntax git checkout my-44x, I got the files in the working area but then the active branch becomes my-44x. If I try to switch to my-53x with git branch m-53x the files disappear from the working area and I cannot commit them in my-53x. They come back in the working area if I run git branch my-44x
git checkout my-cmssw/my-44x -- <package #1>
git checkout my-cmssw/my-44x -- <package #2>
...
  • Add the files of these packages to the index
git add <package #1>/*
git add <package #2>/*
...
  • Commit the files into the branch and before that check what you are going to commit: without the second step you would notice that the git commit command would delete many files...
git status
git commit -m "<comment>"
git push my-cmssw my-53x

Option 2

Using git cherry-pick command:
  • Clone without any real copy of the files the personal branch where the new packages hav to be put
git clone -n -b my-62x -o my-cmssw git@github.com:venturia/cmssw.git $CMSSW_BASE/src
  • Checkout at least one package from the branch. This is really ugly but without that the next git cherry-pick command will not work since it thinks that you still have to commit changes, namely the deletion of all the files. It seems that it is much better to checkout the packages which are affected by the commits you want to cherry-pick
git config core.sparsecheckout true
echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
git checkout
Identify the id of the commit done in another branch and that you want to repeat in the present branch. The git web page can help. Then issue:
git cherry-pick [-e] [-n] <commit-id>
where -e is needed if you want to change the comment of the commit and not use the same comment used for the commit in the old branch, and -n is needed not to do the commit which, then, has to be done by hand later.

Note when I run git cherry-pick ... I got strange error messages about other files in other packages!!

How to build a complex working area for analysis AND development

Option 1

A possible way is the following:

cmsrel CMSSW_4_4_5_patch3
cd CMSSW_4_4_5_patch3/src
cmsenv
git init
git remote add my-cmssw git@github.com:venturia/cmssw.git
git config core.sparsecheckout true
echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
echo TrackingPFG/Configuration >> .git/info/sparse-checkout
echo TrackingPFG/Utilities >> .git/info/sparse-checkout
echo TrackingPFG/TrackJets >> .git/info/sparse-checkout
echo DebugTools/RecHits >> .git/info/sparse-checkout
echo DebugTools/OverlapProblem >> .git/info/sparse-checkout
echo DebugTools/BSSlope >> .git/info/sparse-checkout
echo tracking/TrackRecoMonitoring >> .git/info/sparse-checkout
echo trackCount/TrackCount >> .git/info/sparse-checkout
echo UserCode/TrackerTrackMixing >> .git/info/sparse-checkout
echo TKDPG/BXSelect >> .git/info/sparse-checkout
echo myAnalyzers/V0RecoAnalyzer >> .git/info/sparse-checkout
echo myProducers/V0CandProducer >> .git/info/sparse-checkout
git pull my-cmssw my-44x
git cms-cvs-history import V00-02-01-01 DPGAnalysis/Skims
git cms-cvs-history import V19-03-10 DataFormats/V0Candidate
git cms-cvs-history import V03-03-00 RecoLuminosity/LumiDB
git cms-cvs-history import V05-01-01  RecoLuminosity/LumiProducer
git cms-cvs-history import V00-13-04-04-17 Validation/RecoVertex

After that I got:

[lxplus415] /afs/cern.ch/work/v/venturia/CMSSW_4_4_5_patch3/src $ git branch
* master
[lxplus415] /afs/cern.ch/work/v/venturia/CMSSW_4_4_5_patch3/src $ git remote
DPGAnalysis-Skims
DataFormats-V0Candidate
RecoLuminosity-LumiDB
RecoLuminosity-LumiProducer
Validation-RecoVertex
my-cmssw

What can I do with master ? Furthermore with git status I got a list of "untracked" files. They are either the files created by scramv1 b or the files in the packages that I have downloaded with git cms-cvs-history import ... which are "new". BUT if I run git diff <package-name> I do not get any difference for the files which have changed. So I do not understand why the new files are highlighted but the modified files are not.

Option 2

Another possible way of doing it (from CMS/TrackingPFGJob):

cmsrel CMSSW_4_4_5_patch3
cd CMSSW_4_4_5_patch3/src
cmsenv
git clone -n -b my-44x -o my-cmssw git@github.com:venturia/cmssw.git $CMSSW_BASE/src
git config core.sparsecheckout true
echo DPGAnalysis/SiStripTools > .git/info/sparse-checkout
echo TrackingPFG/Configuration >> .git/info/sparse-checkout
echo TrackingPFG/Utilities >> .git/info/sparse-checkout
echo TrackingPFG/TrackJets >> .git/info/sparse-checkout
echo DebugTools/RecHits >> .git/info/sparse-checkout
echo DebugTools/OverlapProblem >> .git/info/sparse-checkout
echo DebugTools/BSSlope >> .git/info/sparse-checkout
echo tracking/TrackRecoMonitoring >> .git/info/sparse-checkout
echo trackCount/TrackCount >> .git/info/sparse-checkout
echo UserCode/TrackerTrackMixing >> .git/info/sparse-checkout
echo TKDPG/BXSelect >> .git/info/sparse-checkout
echo myAnalyzers/V0RecoAnalyzer >> .git/info/sparse-checkout
echo myProducers/V0CandProducer >> .git/info/sparse-checkout
git checkout
git cms-cvs-history import V00-02-01-01 DPGAnalysis/Skims
git cms-cvs-history import V19-03-10 DataFormats/V0Candidate
git cms-cvs-history import V03-03-00 RecoLuminosity/LumiDB
git cms-cvs-history import V05-01-01  RecoLuminosity/LumiProducer
git cms-cvs-history import V00-13-04-04-17 Validation/RecoVertex

After that I got this:

[lxplus412] /afs/cern.ch/cms/tracking/workareas/git_workareas/CMSSW_4_4_5_patch3/src $ git remote
DPGAnalysis-Skims
DataFormats-V0Candidate
RecoLuminosity-LumiDB
RecoLuminosity-LumiProducer
Validation-RecoVertex
my-cmssw
[lxplus412] /afs/cern.ch/cms/tracking/workareas/git_workareas/CMSSW_4_4_5_patch3/src $ git branch
* my-44x

Some comment as above for git diff: it is not able to spot any difference w.r.t. my-44x but git status detects all the files which I have downloaded with git cms-cvs-history import ... and which are not in the corresponding packages in my-44x What does it mean

What if I do a git clone ... without -n and with sparse checkout? To be tried

Stuff

Comments

  • Looking at the code of git-cms-addpkg I have the impression that the line: git clone --bare https://github.com/cms-sw/cmssw.git $CMSSW_GIT_REFERENCE is quite heavy if performed on a personal repository and without profiting of the fact that $CMSSW_GIT_REFERENCE is a CMS file
  • I am asked for a password when I do git push ...
Edit | Attach | Watch | Print version | History: r26 < r25 < r24 < r23 < r22 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r26 - 2014-10-27 - AndreaVenturi
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback