git tutorial

git and content versioning

clone make a copy of a repository

repository present code and history stored somewhere (local/remote)

working copy local copy of present code that you can modify

add prepare to track working copy modifications

commit store modifications in local repository

push store local repository updates in remote repository

Exercise 1: git and git clone

git is a distributed content versioning system. A content versioning system, keeps copies of code. This makes it easy to keep track of complicated codes and code changes. At a first order, you will be using git to interact with the GEOS-Chem repository. The first command you run is `git clone` following the instructions in the GEOS-Chem manual. You can get more information on git commands using `git help [command]`.

1. Login to HPC using putty

2. Change directories to your home directory (`cd ~`)

3. Make a code directory by executing `mkdir code'

4. change directories to your code directory (cd code)

5. execute `git clone git://git.as.harvard.edu/bmy/GEOS-Chem Code.v9-01-03`

6. execute `git checkout tags/Fix_for_IFORT12`

7. If you have already done this, you'll get an error and you should ignore it. Now, compare the line you excuted with the git help on clone (`git help clone`)

8. Using the words from the SYNOPSIS help section, what are the two arguments following the `clone` command? __________ and ________________

Exercise 2: git commit

In your work with GEOS-Chem or other models, it is useful to track what you've done. This is particularly true when you are running multiple versions of a simulation. Because GEOS-Chem uses git, we can track the changes we've made in our local repository. In this exercise, we will modify and update an arbitrary file.

1. Open FileZilla

2. Change directories to your code directory (double click on Code.v9-01-03)

3. Right click on REVISIONS and choose “View/Edit”

(a) This time you will have to choose your editor

(b) Select custom application and point it to your Notepad++ installation

(c) When Notepad++ opens, choose "Preferences" from the "Settings" menu.

(d) Go to the "Language Menu/Tab Settings" tab and uncheck "Replace by space" in the bottom right

(e) check “Always use selection for unassociated files”

(f) Click close

4. Add your name to the end of this file and close the file

5. Go back to FileZilla choose “Finish editing and upload”

6. Go back to putty (login if necessary)

7. Change directories to the code directory (`cd Code.v9-01-03`)

8. execute `git status`

9. To prepare a file to be “committed”, use `git add REVISIONS` (use `git help add` for more details) `git add REVISIONS`

10. execute `git status`

11. To “commit” a file use `git commit -m “Added my name” REVISIONS` where the message (-m “”) is some meaningful note about what you've done (in this case the message is "Added my name").

12. execute `git status`