shifting most hosting to GitHub All Seismology code has been migrated: Specfem1D Specfem2D Specfem3D Specfem3D Globe Mineos Flexwin AxiSEM Also code for Computational Science, Geodynamo, Long-Term Tectonics, Mantle Convection, Short-Term Crustal Dynamics 2 / 45
backups Flexible workflow Quick and easy branching Frictionless context switching Role-based codelines Feature based workflow Disposable experimentation Small and fast — One or two orders of magnitude faster than SVN (except cloning) Repository integrity — Files, commit messages, dates Staging area — Flexible committing Free and open source — GNU GPL 2.0 1http://git-scm.com/about/ 3 / 45
project Files, Changes, Author names, Dates, etc. Commit Atomic record of changes to files, Author (and committer) of change, Date Branch Name for a commit that follows new commits (e.g., amazing-new-feature) Tag Immovable name for a commit (e.g., v1.0) Operations Clone — Download a copy of history Commit — Record your changes Fetch — Download new changes Merge — Combine new changes with existing files ... 5 / 45
6 5 4 3 2 Central Repository specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Modified Working Directory svn com m it 8 / 45
6 5 4 3 2 Central Repository 10 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer g it fetc h 13 / 45
be shortened); based on: Tree of files Parent commit(s) Commit message Author name/email/timestamp Committer name/email/timestamp Form a Directed Acyclic Graph, referenced by: Child commits Branches Tags HEAD (Working Directory link) The reflog (advanced, but useful at times) 14 / 45
can be: HTTPS: https://github.com/geodynamics/specfem3d_globe.git SSH: [email protected]:geodynamics/specfem3d_globe.git File: file:///path/to/specfem3d_globe Local Path: /home/elliott/specfem3d_globe Creates additional branches in local repository named <remote name>/<remote branch> 15 / 45
2 Central Repository 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer (possible) rem o te 16 / 45
’User Name’ $ git config --global user.email ’[email protected]’ Set name and email on GitHub also Add SSH key to GitHub for password-less access 17 / 45
’User Name’ $ git config --global user.email ’[email protected]’ Set name and email on GitHub also Add SSH key to GitHub for password-less access Conveniences $ git config --global color.ui auto $ git config --global push.default simple 17 / 45
that tracks upstream $ git branch --track devel origin/devel Branch origin/devel set up to track local branch devel # Switch to branch $ git checkout devel Switched to branch ‘devel’ Your branch is up-to-date with ‘origin/devel’. 21 / 45
at HEAD – Short $ git log --oneline 2878904 Merge pull request #62 from QuLogic/typos 2f0c52e Fix some small typos. fedf291 Merge pull request #61 from QuLogic/regular-k 6cea702 Save some memory on addressing array. 433edf7 Use addressing to find regular grid slices. eeeeb36 Round chunk_map output to the nearest EPS. 672b5e6 Use specfem modules to reduce subroutine argu 811ae11 Merge pull request #60 from komatits/devel 163240c simpler implementation of volume and area cal 32686e3 Fix allocation of regular kernel arrays. e27d871 Merge pull request #59 from komatits/devel 26 / 45
new changes $ git log --oneline devel..origin/devel f218984 Merge pull request #88 from komatits/devel a5dde6d added an email from Daniel Peter about ellipt f2de2cd Merge pull request #87 from komatits/devel ffd536a renamed model_crust to model_crust_2_0 to be e63245c Merge pull request #86 from komatits/devel 2614dd9 done cleaning and adding all the topography ba3f67c Merge pull request #85 from komatits/devel 04ab1bc replaced the old version of ETOPO with the 97da690 Merge pull request #84 from komatits/devel 85124e8 compressed the large topo files that are 0e84408 Merge pull request #83 from komatits/devel 27 / 45
contain work on a single feature Recommended (but not required) development workflow Completely local (unless explicitly shared) Allows you to switch between work topics quickly Creating a Feature Branch # Create and switch to branch feature-one $ git checkout -b feature-one devel Switched to branch ‘feature-one’ # Switch back to branch devel $ git checkout devel Switched to branch ‘devel’ 31 / 45
contain work on a single feature Recommended (but not required) development workflow Completely local (unless explicitly shared) Allows you to switch between work topics quickly Deleting a Feature Branch # Switch back to branch devel $ git checkout devel Switched to branch ‘devel’ # Delete branch feature-one $ git branch -d feature-one Deleted branch feature-one (was 6106a0c). 31 / 45
contain work on a single feature Recommended (but not required) development workflow Completely local (unless explicitly shared) Allows you to switch between work topics quickly Listing Branches $ git branch * devel master 31 / 45
contain work on a single feature Recommended (but not required) development workflow Completely local (unless explicitly shared) Allows you to switch between work topics quickly Listing All Branches (including remotes) $ git branch -a * devel master remotes/origin/devel remotes/origin/master remotes/upstream/devel remotes/upstream/master 31 / 45
branch devel Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: DATA (new commits) modified: src/specfem3D/specfem3D.F90 no changes added to commit (use "git add" and/or "git commit -a") 32 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow git checkout 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow git add 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow git commit 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow 34 / 45
stores changes to be committed 10 9 8 7 6 5 Local Repository Index src Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Information Flow Option --cached makes commands work in reference to index git diff compares index with working directory git diff --cached compares HEAD with index 34 / 45
Commit Messages Capitalized, short (50 chars or less) summary More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. 38 / 45
when upstream changes lines you have also changed Produces conflict markers <<<===>>> in conflicting files Status shows conflicting files Must be added to index to resolve conflict Conflict Statusg $ git status ... Unmerged paths: (use "git add ..." to mark resolution) both modified: src/specfem3D/specfem3D.F90 39 / 45
when upstream changes lines you have also changed Produces conflict markers <<<===>>> in conflicting files Status shows conflicting files Must be added to index to resolve conflict Resolving Conflicts $ git mergetool 39 / 45
when upstream changes lines you have also changed Produces conflict markers <<<===>>> in conflicting files Status shows conflicting files Must be added to index to resolve conflict Resolving Conflicts $ git mergetool --tool=meld 39 / 45
when upstream changes lines you have also changed Produces conflict markers <<<===>>> in conflicting files Status shows conflicting files Must be added to index to resolve conflict Resolving Conflicts $ git mergetool --tool=meld # Permanent tool setting $ git config --global merge.tool meld 39 / 45
in another Changes, commits, etc. are local to submodule Parent just sees a single directory — always treat it as such git fetch in parent will automatically fetch submodules git fetch in submodule will not fetch parent git submodule update to keep submodule in sync with parent’s expectations 40 / 45
In global code, DATA, EXAMPLES, and m4 are submodules Not hosted on GitHub, but on CIG servers Must obtain push access permission from them Must change remote URL to use SSH key (see wiki) Changes must be committed “twice” 1 Commit changes to submodule (i.e., DATA, EXAMPLES, or m4) 2 Commit new ID in parent 41 / 45
changes from your fork into the Geodynamics repository If available, set base branch to devel Set head branch to feature branch in your fork or devel 43 / 45
to files line-by-line $ git commit --amend — Fix a previous commit (do not do this to public commits) $ git rebase [--interactive] — Re-create commits on top of another commit (do not do this to public commits) $ git cherry-pick — Copy commits from one branch to another $ gitk — Viewer for git history (built-in) $ gitg — Viewer for git history (separate install) 44 / 45