Newer
Older
* LaTeX resources
Reusable LaTeX resources (figures, lists, tables, equations) for documents (presentations, theses, papers).
This README explains how to reuse these resources via ~git submodule~. An
alternative is ~git subtree~. Here is a general advice on which one to choose
for what.
#+begin_quote
If there is an external repository you own and are likely to push code back to,
use Git submodule since it is easier to push. If you have third-party code that
you are unlikely to push to, use Git subtree since it is easier to pull.
Reference: [[https://opensource.com/article/20/5/git-submodules-subtrees][opensource.com > Managing Git projects with submodules and subtrees]]
#+end_quote
I have only used ~git submodule~ so far, and I am happy with it.
** Using these resources via ~git submodule~
*** Adding these resources to a project
If you want to use these resources in a project,
#+begin_src shell
cd myproject
git submodule add https://iffgit.fz-juelich.de/phd-project-wasmer/resources/latex-resources resources
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#+end_src
Now your project has the folder ~resources~, pointing to the last commit of this
repo.
*** Using a project which use these resources
#+begin_src shell
# clone a repository containing submodules:
git clone --recursive <URL to Git repo>
# if there are many submodules, parallelize download
git submodule update --init --recursive -j 8
git clone --recursive --jobs 8 <URL to Git repo>
# you have already cloned a repository with submodules,
# and now want to load its submodules:
git submodule update --init --recursive
# pull all changes in submodules
git submodule update --remote
# update submodule commits
git submodule update
#+end_src
*** Changing these resources
My workflow for keeping projects and their Git submodules in sync:
- say you got =./a/b=, =./b=. =a= is the main project, =b= another project
acting as submodule of =a=. So locally, you got two copies of =b=: =./b=, and
=./a/b=, where the latter behaves like a submodule.
- Make changes in the submodule =./a/b=, not in =./b=. Then don't ever need the
~git submodule~ command for normal add-commit-push-pull cycles. If only using
=b= for =a=, then in fact never need to do anything with =./b=, can do
everything in =./a/b=.
- Make changes to =./a/b=. Within =./a/b=, add-commit-push to origin of =b=.
- Go up to =./a=. add-commit-push the changes to the submodule with commit
message like 'update submodules'.
- If got an independent local copy =./b= of =b=, go to =./b= and pull.
- Done, all copies are synched.
*** Other submodule commands
#+begin_src shell
# initialize an existing Git submodule:
git submodule init
# rename a submodule folder in a project
git mv old-name new-name
# delete / remove submodule from parent
# note: see also https://stackoverflow.com/a/1260982/8116031
git rm -f childmodule
#+end_src
** TODO Replace local resources in ML-DFT literature review
** TODO Replace local resources in master thesis