Git and Julia Tips for CliMA.Land
Instantiate the project
The Land project
cd .../Land
to the home directory of the projectjulia --project
using Pkg
Pkg.instantiate()
- Delete the file
Manifest.toml
when encountering errors - Redo
Pkg.instantiate()
The docs/ project
cd .../Land/docs
julia --project
using Pkg
Pkg.instantiate()
- Delete the file
Manifest.toml
when encountering erros - Delete the line
Land="*"
in theProject.toml
- Type
]
in the julia REPL to enter the pkg environment dev ..
oradd ..
to add the Land project- Redo
Pkg.instantiate()
Run local tests before merging into main
- Optional: load the Land project
cd .../Land
to the home directory of the projectjulia --project
using Land
to make sure the project can be loaded
- Optional: disable the example to save some time
- change
generate_examples = true
togenerate_examples = false
in filedocs/examples.jl
- change the line back to
generate_examples = true
before commiting the changes
- change
- Optional: initialize the project
cd .../Land
to the home directory of the projectjulia --project -e "using Pkg; Pkg.instantiate(); Pkg.build(); Pkg.precompile();"
julia --project=docs/ -e "using Pkg; Pkg.instantiate(); Pkg.build(); Pkg.precompile();"
- Test the documentation project
julia --project=docs/ docs/make.jl
- Fix errors and warnings associated with Land project
- Test the Land project
julia --project -e "using Pkg; Pkg.test();"
- Resolve failed tests
Rebase the commits before merging into main
- Switch to the feature branch and make sure you have a clean workspace
git checkout FeatureBranch
git status
to confirm zero uncommitted changes
- Backup current branch to avoid unexpected errors
git checkout -b FeatureBranch_Backup
- Sync the main branch
git checkout main
git pull
- Switch to the feature branch and merge main into it
git checkout FeatureBranch
git status
to confirm zero uncommitted changesgit merge main
- Resolve conflicts and commit them if any
- Reabse the feature branch
git reset origin/main
to rewrite historygit diff
(optional) would show all the changesgit add --all
to add local changes on top of maingit commit -m "Single commit message"
git push -f
to force push because of the re-written history
- Create a Pull Request
- Through the web
- Remove local unnecessary branch (e.g., FeatureBranch_backup)
git branch -d FeatureBranch_Backup
git branch -D FeatureBranch_Backup
to force remove