Skip to content

Instantly share code, notes, and snippets.

@mathomp4
Last active March 6, 2023 14:32
Show Gist options
  • Save mathomp4/1357c3a04641d2f1a2c468481e1c131c to your computer and use it in GitHub Desktop.
Save mathomp4/1357c3a04641d2f1a2c468481e1c131c to your computer and use it in GitHub Desktop.
Moving MITgcm code from GCM GC repo to Ocean preserving the history

Much of this is based on https://vivekdhami.com/post/git-move-repo-files-with-history/

  1. First you need some preliminaries. If you are on a mac, you can do:
brew install git-filter-repo

If you are on discover, do:

module load python/GEOSpyD/Min4.11.0_py3.9 other/git-filter-repo
  1. Clone the two repos we need
git clone [email protected]:GEOS-ESM/GEOS_OceanGridComp.git
git clone [email protected]:GEOS-ESM/GEOSgcm_GridComp.git
  1. Checkout the branch in GCM GC
cd GEOSgcm_GridComp
git checkout feature/atrayano/MITgcm-DYAMOND
  1. Use filter-repo to abstract just the Ocean Grid Comp directory
git filter-repo --subdirectory-filter GEOSogcm_GridComp/GEOS_OceanGridComp --force
  1. Use filter-repo to get just the files we care about
git filter-repo --path CMakeLists.txt --path GEOS_OceanGridComp.F90 --path MIT_GEOS5PlugMod --force
  1. Now we move to the other repo
cd ../GEOS_OceanGridComp
  1. Add source repo as a remote
git remote add source-repo ../GEOSgcm_GridComp
  1. Grab the branch we need
git fetch source-repo
...
git branch feature/atrayano/MITgcm-DYAMOND remotes/source-repo/feature/atrayano/MITgcm-DYAMOND
  1. When you clone GEOS_OceanGridComp, you are on develop, so we make a new branch
git checkout -b merge-mitgcm
  1. Now merge
git merge feature/atrayano/MITgcm-DYAMOND --allow-unrelated-histories

In my testing this threw a couple conflicts:

Auto-merging CMakeLists.txt
CONFLICT (add/add): Merge conflict in CMakeLists.txt
Auto-merging GEOS_OceanGridComp.F90
CONFLICT (add/add): Merge conflict in GEOS_OceanGridComp.F90
Automatic merge failed; fix conflicts and then commit the result.

that need solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment