nested_repos.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # This script was converted using cast2script from:
  3. # docs/casts/seamless_nested_repos.sh
  4. set -e -u
  5. export GIT_PAGER=cat
  6. # DataLad provides seamless management of nested Git repositories...
  7. # Let's create a dataset
  8. datalad create demo
  9. cd demo
  10. # A DataLad dataset is just a Git repo with some initial configuration
  11. git log --oneline
  12. # We can generate nested datasets, by telling DataLad to register a
  13. # new dataset in a parent dataset
  14. datalad create -d . sub1
  15. # A subdataset is nothing more than regular Git submodule
  16. git submodule
  17. # Of course subdatasets can be nested
  18. datalad create -d . sub1/justadir/sub2
  19. # Unlike Git, DataLad automatically takes care of committing all
  20. # changes associated with the added subdataset up to the given
  21. # parent dataset
  22. git status
  23. # Let's create some content in the deepest subdataset
  24. mkdir sub1/justadir/sub2/anotherdir
  25. touch sub1/justadir/sub2/anotherdir/afile
  26. # Git can only tell us that something underneath the top-most
  27. # subdataset was modified
  28. git status
  29. # DataLad saves us from further investigation
  30. datalad diff -r
  31. # Like Git, it can report individual untracked files, but also across
  32. # repository boundaries
  33. datalad diff -r --report-untracked all
  34. # Adding this new content with Git or git-annex would be an exercise
  35. git add sub1/justadir/sub2/anotherdir/afile || true
  36. # DataLad does not require users to determine the correct repository
  37. # in the tree
  38. datalad add -d . sub1/justadir/sub2/anotherdir/afile
  39. # Again, all associated changes in the entire dataset tree, up to
  40. # the given parent dataset, were committed
  41. git status
  42. # DataLad's 'diff' is able to report the changes from these related
  43. # commits throughout the repository tree
  44. datalad diff --revision @~1 -r