Difference between revisions of "GIT"

From DaqWiki
Jump to navigation Jump to search
(2 intermediate revisions by the same user not shown)
Line 58: Line 58:
 
   204  16:53  cd public_html/
 
   204  16:53  cd public_html/
 
   206  16:54  cd git/
 
   206  16:54  cd git/
   221  17:04  git clone --bare http://root.cern.ch/git/root.git root.git
+
   221  17:04  git clone --mirror http://root.cern.ch/git/root.git root.git
 
   231  17:23  cd root.git/hooks/
 
   231  17:23  cd root.git/hooks/
 
   233  17:23  mv post-update.sample post-update
 
   233  17:23  mv post-update.sample post-update
Line 109: Line 109:
 
  1149  git commit
 
  1149  git commit
 
  1151  git push https://dd1@bitbucket.org/tmidas/test.git
 
  1151  git push https://dd1@bitbucket.org/tmidas/test.git
 +
</pre>
 +
 +
Add alternative git source to your local repository
 +
<pre>
 +
git remote add triumf http://daq.triumf.ca/git/midas.git
 
</pre>
 
</pre>
  
Line 117: Line 122:
 
* http://root.cern.ch/drupal/content/suggested-work-flow-distributed-projects-nosy
 
* http://root.cern.ch/drupal/content/suggested-work-flow-distributed-projects-nosy
 
* https://indico.cern.ch/getFile.py/access?contribId=0&resId=0&materialId=slides&confId=246803
 
* https://indico.cern.ch/getFile.py/access?contribId=0&resId=0&materialId=slides&confId=246803
 
=== BIT BUCKET ===
 
 
Git commands for the [http://bitbucket.org BitBucket]
 
 
Test package committed to this repository: mscbbs
 
 
Wiki available: https://bitbucket.org/pamaudruz/mscbbs/wiki/Home
 
 
Cloning: will make a copy of the bitbucket repository on your local machine
 
'''~/mscbbs/...'''
 
 
password required:
 
<pre>
 
git clone <nowiki>https://pamaudruz@bitbucket.org/pamaudruz/mscbbs.git</nowiki>
 
git clone <nowiki>https://pamaudruz@bitbucket.org/pamaudruz/mscbbs.git/wiki</nowiki>
 
</pre>
 
 
or using ssh private key (set in bitbucket.org account):
 
<pre>
 
git clone git@bitbucket.org:pamaudruz/mscbbs.git
 
git clone git@bitbucket.org:pamaudruz/mscbbs.git/wiki
 
</pre>
 

Revision as of 11:52, 8 August 2013

Create personal "cloneable" repository

This uses the "dual" repository method: the first repository is a bare repository is exported to the world via httpd, the second repository is where all work is done, committed. When ready, the work repository is pushed to the bare repository and becomes visible to the world.

$ cd ~/public_html/git
$ git init --bare rpms.git
Initialized empty Git repository in /home/olchansk/public_html/git/rpms.git/
$ cd rpms/hooks
$ mv post-update.sample post-update
$ chmod a+x ./post-update 
$ cd ~/git/
$ git clone ~/public_html/git/rpms.git rpms
warning: You appear to have cloned an empty repository.
$ cd rpms
$ date > test
$ git add test
$ git commit -m"test"
[master (root-commit) 9236a84] test
$ git push origin master
To /home/olchansk/public_html/git/rpms.git
 * [new branch]      master -> master
$ rm test
$ date > test 
$ git add test
$ git commit -m"test"
[master 54a6b4e] test
$ git push
To /home/olchansk/public_html/git/rpms.git
   9236a84..54a6b4e  master -> master
$ ssh to somewhere else
$ git clone http://ladd00.triumf.ca/~olchansk/git/rpms.git rpms

Merge history from another git repository

$ git fetch file:///home/olchansk/sysadm/rpm/diskscrub/ master:diskscrub_merge
$ git checkout master:diskscrub_merge
$ mkdir diskscrub
$ git add diskscrub
$ git mv *.* diskscrub
$ ls -la
$ git status
$ git commit -m"move into subdirectory" -a
$ git checkout master
$ ls -la
$ git merge diskscrub_merge
$ git log --graph
$ git log --graph --oneline
$ git push

Setup mirror of the ROOT git repository

ssh daqweb@ladd00
   204  16:53   cd public_html/
   206  16:54   cd git/
   221  17:04   git clone --mirror http://root.cern.ch/git/root.git root.git
   231  17:23   cd root.git/hooks/
   233  17:23   mv post-update.sample post-update
   234  17:24   chmod a+x ./post-update

Additional commands:

  • fetch latest version: cd root.git; git fetch; git update-server-info
  • list all version tags: cd root.git; git tag -l
  • list all version branches: cd root.git; git branch

Convert ROOTANA SVN to GIT

  • extract the authors list: svn log -q file:///home/daqweb/svn/rootana | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
  • adjust authors list: vi authors.txt
(no author) = (no author) <(no author)>
daqweb = Konstantin Olchanski <daqweb>
lindner = Thomas Lindner <lindner>
olchansk = Konstantin Olchanski <olchansk>
  • run conversion: git svn clone --stdlayout -A authors.txt file:///home/daqweb/svn/rootana
  • doctor the SVN revision comments: cd rootana; git filter-branch -d /tmp/tmpfs/gitrewrite --msg-filter 'sed "/git-svn-id:/s;^.*/\([^/]*\)@\([0-9]*\).*$;SVN revision: \2;"' -- --all
  • new git commit messages look like this:
commit 84461b29deccf4ce82893f9275f6e44a303943c4
Author: Thomas Lindner <lindner>
Date:   Mon Jul 8 23:30:09 2013 +0000

    Add a sleep to offline/paused display; otherwise program takes 100% of CPU...
    
    
    SVN revision: 133

Push ROOTANA GIT to BITBUCKET

Clone, commit and push to BITBUCKET

 1141  git clone https://bitbucket.org/tmidas/test.git
 1143  cd test
 1145  cd tests
 1147  touch yyy
 1148  git add yyy
 1149  git commit
 1151  git push https://dd1@bitbucket.org/tmidas/test.git

Add alternative git source to your local repository

git remote add triumf http://daq.triumf.ca/git/midas.git

Wisdom from ROOT