Changes between Initial Version and Version 1 of Workshops/IntroToHpc2015/git


Ignore:
Timestamp:
Oct 19, 2015 4:30:44 PM (7 years ago)
Author:
pdejesus
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Workshops/IntroToHpc2015/git

    v1 v1  
     1[[PageOutline]]
     2= Version Control with ''git'' =
     3
     4Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
     5
     6To use git on Cypress, you have to load module. It is better to set this in ''.modulerc'' (see below).
     7{{{#!bash
     8[fuji@cypress2 ~]$ module load git
     9}}}
     10
     11[[Image(GIT_model.png)]]
     12
     13== Create a project repository ==
     14On your project directory, for example, (replace dpg with your project folder name)
     15{{{#!bash
     16[fuji@cypress2 fuji]$ cd projectX
     17[fuji@cypress2 projectX]$ git init
     18Initialized empty Git repository in /lustre/project/dpg/fuji/projectX/.git/
     19}}}
     20
     21Add a file and commit
     22{{{#!bash
     23[fuji@cypress2 projectX]$ echo "This is README.txt for my git-repo" > README.txt
     24[fuji@cypress2 projectX]$ git add README.txt
     25[fuji@cypress2 projectX]$ git commit -m"first commit"
     26[master (root-commit) 4fe9eae] first commit
     27 Committer: Hideki Fujioka <fuji@cypress2.cm.cluster>
     28Your name and email address were configured automatically based
     29on your username and hostname. Please check that they are accurate.
     30You can suppress this message by setting them explicitly. Run the
     31following command and follow the instructions in your editor to edit
     32your configuration file:
     33
     34    git config --global --edit
     35
     36After doing this, you may fix the identity used for this commit with:
     37
     38    git commit --amend --reset-author
     39
     40 1 file changed, 1 insertion(+)
     41 create mode 100644 README.txt
     42}}}
     43
     44You can work with this repository on Cypress.
     45
     46=== Create a Bare Repository ===
     47If you want to make a git server repository, you have to make a Bare Repository. For example,
     48
     49{{{#!bash
     50[fuji@cypress2 dpg]$ mkdir repos
     51[fuji@cypress2 dpg]$ cd repos
     52[fuji@cypress2 repos]$ git clone --bare ../fuji/projectX ./projectX.git
     53}}}
     54
     55Add group write permissions to a repository so that people in your group can pull/push.
     56 {{{#!bash
     57[fuji@cypress2 repos]$ chgrp -R dpg projectX.git
     58[fuji@cypress2 repos]$ chmod -R g+swX projectX.git
     59[fuji@cypress2 repos]$ cd projectX.git
     60[fuji@cypress2 projectX.git]$ git init --bare --shared
     61Reinitialized existing shared Git repository in /lustre/project/dpg/repos/projectX.git/
     62}}}
     63
     64=== Make a Clone Repository ===
     65Make a clone repository on Cypress,
     66{{{#!bash
     67[fuji@cypress2 ~]$ git clone file:///lustre/project/dpg/repos/git/projectX.git
     68Cloning into 'projectX'...
     69remote: Counting objects: 3, done.
     70remote: Total 3 (delta 0), reused 0 (delta 0)
     71Receiving objects: 100% (3/3), done.
     72Checking connectivity... done.
     73[fuji@cypress2 ~]$ ls
     74projectX
     75}}}
     76
     77Make a clone repository over network, (you may have to type password)
     78{{{#!bash
     79Hideki02:~ fuji$ git clone fuji@cypress1.tulane.edu:/lustre/project/dpg/repos/git/projectX.git
     80Cloning into 'projectX'...
     81remote: Counting objects: 3, done.
     82remote: Total 3 (delta 0), reused 0 (delta 0)
     83Receiving objects: 100% (3/3), done.
     84Checking connectivity... done.
     85Hideki02:~ fuji$ ls
     86projectX
     87}}}
     88Since git is not a default module on Cypress, you have to set '''~/.modulerc''' like:
     89{{{#!bash
     90#%Module3.2.10
     91module load git
     92}}}
     93
     94
     95== Free Git Repository ==
     96* [https://bitbucket.org/]
     97* [https://github.com/]
     98
     99
     100== Basic Commands ==
     101
     102=== Add new files ===
     103{{{#!bash
     104Hideki02:projectX fuji$ git add test.txt
     105}}}
     106This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.
     107
     108=== Commit ===
     109{{{#!bash
     110Hideki02:projectX fuji$ git commit -m"message"
     111}}}
     112Stores the current contents of the index in a new commit along with a log message from the user describing the changes. At this point, only your local clone has your modification.
     113
     114=== push ===
     115When you have your project at a point that you want to share with your group people, you have to push it to a master repository.
     116{{{#!bash
     117Hideki02:projectX fuji$ git push
     118}}}
     119You may have to type password for Cypress.
     120
     121=== pull ===
     122To pull current project in the master repository,
     123{{{#!bash
     124Hideki02:projectX fuji$ git pull
     125}}}
     126
     127== Documents ==
     128* [https://git-scm.com/doc]