Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CIG Seismo Code on Git/GitHub

CIG Seismo Code on Git/GitHub

This presentation is an introduction to Git and GitHub as it is used for CIG Seismological code.

Other Decks in Programming

Transcript

  1. CIG Seismo Code on Git/GitHub Elliott Sales de Andrade University

    of Toronto May 16, 2014 cd83b68: v6.0.0 master submodules updated 170e5f7: Update submodules in master c0bc5ba: Merge remote-tracking branch ‘origin/devel’ 754300e: Update README.md 40bcfdd: Merge pull request #68 from QuLogic/readme e2f2928: section-ify readme file.
  2. Outline 1 Introduction What is Git? What is GitHub? Version

    Control Basics 2 Using CIG Code from Git 3 Local Development 4 Sharing and Contributing Code 5 Additional Information 1 / 45
  3. Introduction CIG is transitioning code from Subversion to Git Also

    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
  4. Introduction What is Git? The stupid content tracker1 Distributed Multiple

    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
  5. Introduction What is GitHub? Provides hosting and resources for open

    source software: Issue tracking Tasks Features Pull requests etc. Code review Commit comments, Pull requests, Diffs, etc. Wikis Collaborative tools Statistics 4 / 45
  6. Version Control Concepts Repository Complete copy of entire history of

    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
  7. Version Control Concepts with Subversion Ignore Subversion if possible (Next

    three slides for those who know it already) 6 / 45
  8. Version Control Concepts with Subversion Checkout 9 8 7 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 ... Piero’s Working Directory 7 / 45
  9. Version Control Concepts with Subversion Checkout 9 8 7 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 ... Piero’s Working Directory svn checkout 7 / 45
  10. Version Control Concepts with Subversion Checkout 9 8 7 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 ... Piero’s Working Directory 7 / 45
  11. Version Control Concepts with Subversion Checkout 9 8 7 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 ... Piero’s Working Directory svn checkout 7 / 45
  12. Version Control Concepts with Subversion Commits 10 9 8 7

    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 8 / 45
  13. Version Control Concepts with Subversion Commits 10 9 8 7

    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 Editing 8 / 45
  14. Version Control Concepts with Subversion Commits 10 9 8 7

    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
  15. Version Control Concepts with Subversion Commits 10 9 8 7

    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 8 / 45
  16. Version Control Concepts with Subversion Updating 10 9 8 7

    6 5 4 3 2 Central Repository specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Working Directory 9 / 45
  17. Version Control Concepts with Subversion Updating 10 9 8 7

    6 5 4 3 2 Central Repository specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Working Directory svn update 9 / 45
  18. Version Control Concepts with Subversion Updating 10 9 8 7

    6 5 4 3 2 Central Repository specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Working Directory 9 / 45
  19. Version Control Concepts with Git Cloning 9 8 7 6

    5 4 3 2 Central Repository 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer 11 / 45
  20. Version Control Concepts with Git Cloning 9 8 7 6

    5 4 3 2 Central Repository 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer git clone 11 / 45
  21. Version Control Concepts with Git Cloning 9 8 7 6

    5 4 3 2 Central Repository 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer 11 / 45
  22. Version Control Concepts with Git Cloning 9 8 7 6

    5 4 3 2 Central Repository 9 8 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 7 6 5 Local Repository Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Piero’s Computer git clone 11 / 45
  23. Version Control Concepts with Git Commits 10 9 8 7

    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 ... Modified Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 12 / 45
  24. Version Control Concepts with Git Commits 10 9 8 7

    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 ... Modified Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer Editing 12 / 45
  25. Version Control Concepts with Git Commits 10 9 8 7

    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 ... Modified Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer git commit 12 / 45
  26. Version Control Concepts with Git Commits 10 9 8 7

    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 ... Modified Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer 12 / 45
  27. Version Control Concepts with Git Commits 10 9 8 7

    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 ... Modified Working Directory specfem3d_globe DATA doc EXAMPLES setup src utils ... Elliott’s Computer git push 12 / 45
  28. Version Control Concepts with Git Updating 10 9 8 7

    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 13 / 45
  29. Version Control Concepts with Git Updating 10 9 8 7

    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
  30. Version Control Concepts with Git Updating 10 9 8 7

    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 git merge 13 / 45
  31. Version Control Concepts with Git Updating 10 9 8 7

    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 13 / 45
  32. Git Basics Commits Denoted by SHA1 hash, e.g., cd83b686a7c6014e132933f685157d43151a665e (can

    be shortened); based on: Tree of files Parent commit(s) Commit message Author name/email/timestamp Committer name/email/timestamp 14 / 45
  33. Git Basics Commits Denoted by SHA1 hash, e.g., cd83b686a7c6014e132933f685157d43151a665e (can

    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
  34. Git Basics Remotes Remotes are references to other repositories; URIs

    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
  35. Git Basics Remotes 9 8 7 6 5 4 3

    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 remote remote 16 / 45
  36. Git Basics Remotes 9 8 7 6 5 4 3

    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
  37. Git Basics Configuration User Name $ git config --global user.name

    ’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
  38. Git Basics Configuration User Name $ git config --global user.name

    ’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
  39. Using CIG Code from Git Cloning Stable Code $ git

    clone --recursive \ https://github.com/geodynamics/specfem3d_globe.git Cloning into ‘specfem3d_globe’... remote: Reusing existing pack: 20478, done. remote: Counting objects: 59, done. remote: Compressing objects: 100% (59/59), done. done. Checking out files: 100% (701/701), done. ... 19 / 45
  40. Using CIG Code from Git Cloning Stable Code $ git

    clone --recursive \ https://github.com/geodynamics/specfem3d_globe.git Cloning into ‘specfem3d_globe’... remote: Reusing existing pack: 20478, done. remote: Counting objects: 59, done. remote: Compressing objects: 100% (59/59), done. done. Checking out files: 100% (701/701), done. ... 19 / 45
  41. Using CIG Code from Git Cloning Development Code $ git

    clone --recursive --branch devel \ https://github.com/geodynamics/specfem3d_globe.git Cloning into ‘specfem3d_globe’... remote: Reusing existing pack: 20478, done. remote: Counting objects: 59, done. remote: Compressing objects: 100% (59/59), done. done. Checking out files: 100% (701/701), done. ... 20 / 45
  42. Using CIG Code from Git Switching Branches # Create branch

    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
  43. Using CIG Code from Git Shortcut # Create and switch

    to branch devel $ git checkout --track -b devel origin/devel Branch origin/devel set up to track local branch devel Switched to branch ‘devel’ 21 / 45
  44. Using CIG Code from Git Shortcut # Create and switch

    to branch devel $ git checkout --track -b devel origin/devel Branch origin/devel set up to track local branch devel Switched to branch ‘devel’ 21 / 45
  45. Using CIG Code from Git Fetching Updates $ git fetch

    remote: Counting objects: 85, done. remote: Compressing objects: 100% (85/85), done. remote: Total 85 (delta 37), reused 2 (delta 0) Unpacking objects: 100% (85/85), done. From https://github.com/geodynamics/specfem3d_globe c45b60b..f218984 devel -> origin/devel 22 / 45
  46. Using CIG Code from Git Fetching Updates $ git fetch

    origin remote: Counting objects: 85, done. remote: Compressing objects: 100% (85/85), done. remote: Total 85 (delta 37), reused 2 (delta 0) Unpacking objects: 100% (85/85), done. From https://github.com/geodynamics/specfem3d_globe c45b60b..f218984 devel -> origin/devel 22 / 45
  47. Using CIG Code from Git Reviewing Updates # Log starting

    at HEAD $ git log commit 28789049bdcb5d51cbef122842a5e1bf9cd7376d Merge: fedf291 2f0c52e Author: Dimitri Komatitsch <komatits@...> Date: Thu May 1 09:48:38 2014 +0200 Merge pull request #62 from QuLogic/typos Fix some small typos. 23 / 45
  48. Using CIG Code from Git Reviewing Updates # Log of

    changes with differences $ git log --patch # or -p commit 2f0c52e3555c6d534baf40084c5f59f7fd6bc7bc Author: Elliott Sales de Andrade <...> Date: Wed Apr 30 23:32:33 2014 -0400 Fix some small typos. diff –git a/src/auxiliaries/combine_paraview_strain_ index 4c1fe2a..ea6d238 100644 –- a/src/auxiliaries/combine_paraview_strain_data.f9 +++ b/src/auxiliaries/combine_paraview_strain_data.f9 @@ -106,3 +106,3 @@ program combine_paraview_movie_da - ! open paraview output mesh file + ! open Paraview output mesh file write(mesh_file,’(a,a,a,i6.6,a)’) ’movie3D_’,tr 24 / 45
  49. Using CIG Code from Git Reviewing Updates # Log of

    changes with statistics $ git log --stat commit 2f0c52e3555c6d534baf40084c5f59f7fd6bc7bc Author: Elliott Sales de Andrade <...> Date: Wed Apr 30 23:32:33 2014 -0400 Fix some small typos. src/auxiliaries/combine_surf_data.f90 | 4 +- src/auxiliaries/combine_vol_data.F90 |18 ++-- src/auxiliaries/create_movie_AVS_DX.f90 | 6 +- src/auxiliaries/create_movie_GMT_global.f90|10 +-- src/cuda/assemble_MPI_scalar_cuda.cu |10 +-- src/cuda/assemble_MPI_vector_cuda.cu |14 +-- src/cuda/check_fields_cuda.cu | 2 +- 25 / 45
  50. Using CIG Code from Git Reviewing Updates # Log starting

    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
  51. Using CIG Code from Git Reviewing Updates # Log of

    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
  52. Using CIG Code from Git Merge Updates $ git merge

    Updating c45b60b..f218984 Fast-forward ... 28 / 45
  53. Using CIG Code from Git Merge Updates $ git merge

    origin/master Updating c45b60b..f218984 Fast-forward ... 28 / 45
  54. Local Development Forking Push access to Geodynamics repos on GitHub

    restricted How to share code? Create a fork (personal GitHub copy of repo): 9 8 7 6 5 Geodynamics Repository 9 8 7 6 5 Personal Repository Fork 29 / 45
  55. Local Development Forking Set remotes for both repos (conventions): origin

    to your fork upstream to Geodynamics repo Setting Remotes # Clone your fork $ git clone --recursive \ https://github.com/username/specfem3d_globe.git # Add remote for Geodynamics repo $ git remote add upstream \ https://github.com/geodynamics/specfem3d_globe.git $ git fetch upstream 30 / 45
  56. Using CIG Code from Git Feature Branches Short-lived branches that

    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
  57. Using CIG Code from Git Feature Branches Short-lived branches that

    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
  58. Using CIG Code from Git Feature Branches Short-lived branches that

    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
  59. Using CIG Code from Git Feature Branches Short-lived branches that

    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
  60. Local Development Reviewing Changes Checking Status $ git status On

    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
  61. Local Development Reviewing Changes Viewing Diffs $ git diff master

    -- src/ diff --git a/src/specfem3D/specfem3D.F90 b/src/.. index 3ba52f2..2b619bf 100644 --- a/src/specfem3D/specfem3D.F90 +++ b/src/specfem3D/specfem3D.F90 @@ -466,6 +466,6 @@ ! sets up and precomputes simulation arrays call prepare_timerun() - ! steps through time iterations + ! Test change if( UNDO_ATTENUATION ) then call iterate_time_undoatt() 33 / 45
  62. Local Development Working with the Index Index or staging area

    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
  63. Local Development Working with the Index Index or staging area

    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
  64. Local Development Working with the Index Index or staging area

    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
  65. Local Development Working with the Index Index or staging area

    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
  66. Local Development Working with the Index Index or staging area

    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
  67. Local Development Working with the Index Index or staging area

    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
  68. Local Development Working with the Index Index or staging area

    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
  69. Local Development Working with the Index Adding New Files $

    git add <new file> Removing Existing Files $ git rm <file> 35 / 45
  70. Local Development Working with the Index Adding New Files $

    git add <new file> Removing Existing Files $ git rm <file> Removing Newly Added Files (i.e., from index) $ git rm --cached <file> 35 / 45
  71. Local Development Working with the Index Adding Changes in Files

    # Add changes from file, patch-by-patch $ git add --patch # or -p 36 / 45
  72. Local Development Working with the Index Adding Changes in Files

    # Add changes from file, patch-by-patch $ git add --patch # or -p # Add entire change of file (not recommended) $ git add <modified file> 36 / 45
  73. Local Development Working with the Index Adding Changes in Files

    # Add changes from file, patch-by-patch $ git add --patch # or -p # Add entire change of file (not recommended) $ git add <modified file> # Add all changes of tracked files (not recommended) $ git add --all 36 / 45
  74. Local Development Working with the Index Undo Changes to Files

    # Remove changes to files # (will match index) $ git checkout -- <files> 37 / 45
  75. Local Development Working with the Index Undo Changes to Files

    # Remove changes to files # (will match index) $ git checkout -- <files> # Remove changes from index # (working directory unaltered) $ git reset 37 / 45
  76. Local Development Working with the Index Undo Changes to Files

    # Remove changes to files # (will match index) $ git checkout -- <files> # Remove changes from index # (working directory unaltered) $ git reset -- <files> 37 / 45
  77. Local Development Working with the Index Undo Changes to Files

    # Remove changes to files # (will match index) $ git checkout -- <files> # Remove changes from index # (working directory unaltered) $ git reset -- <files> # Remove changes from files and index $ git reset --hard 37 / 45
  78. Local Development Committing Committing Changes in Index $ git commit

    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
  79. Using CIG Code from Git Merging may cause conflicts —

    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
  80. Using CIG Code from Git Merging may cause conflicts —

    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
  81. Using CIG Code from Git Merging may cause conflicts —

    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
  82. Using CIG Code from Git Merging may cause conflicts —

    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
  83. Submodules (or, “Why git clone --recursive?”) Completely independent repositories referenced

    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
  84. Submodules Committing Specfem1d is only repository that doesn’t use submodules

    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
  85. Sharing Code Pushing commits only possible to bare repositories (i.e.,

    GitHub, but not other clones) — Must pull from non-bare repositories Pushing Changes $ git push Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.80 KiB | 1 KB/s, done. Total 9 (delta 6), reused 0 (delta 0) To [email protected]:QuLogic/specfem3d_globe.git 26ffb01..ab843d1 master -> master 42 / 45
  86. Sharing Code Pushing commits only possible to bare repositories (i.e.,

    GitHub, but not other clones) — Must pull from non-bare repositories Pushing Changes $ git push origin Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.80 KiB | 1 KB/s, done. Total 9 (delta 6), reused 0 (delta 0) To [email protected]:QuLogic/specfem3d_globe.git 26ffb01..ab843d1 master -> master 42 / 45
  87. Sharing Code Pushing commits only possible to bare repositories (i.e.,

    GitHub, but not other clones) — Must pull from non-bare repositories Pushing Changes $ git push origin master Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.80 KiB | 1 KB/s, done. Total 9 (delta 6), reused 0 (delta 0) To [email protected]:QuLogic/specfem3d_globe.git 26ffb01..ab843d1 master -> master 42 / 45
  88. Sharing Code Pushing commits only possible to bare repositories (i.e.,

    GitHub, but not other clones) — Must pull from non-bare repositories Pushing Changes $ git push origin master:remote-name Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.80 KiB | 1 KB/s, done. Total 9 (delta 6), reused 0 (delta 0) To [email protected]:QuLogic/specfem3d_globe.git 26ffb01..ab843d1 master -> master 42 / 45
  89. Pull Requests Pull Requests indicate that you wish to merge

    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
  90. Useful Commands $ git blame — See who made changes

    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
  91. Additional Information Git - Tutorial by Lars Vogel Git Cheat

    Sheet Git tips for developers on Specfem3D wiki Pro Git book Try Git in your browser 45 / 45