Initialize a Git repository for a targets data store.
Usage
tar_git_init(
store = targets::tar_config_get("store"),
stash_gitignore = TRUE,
git_lfs = TRUE,
verbose = TRUE
)Arguments
- store
Character of length 1, path to the data store of the pipeline. If
NULL, thestoresetting is left unchanged in the YAML configuration file (default:_targets.yaml). Usually, the data store lives at_targets. Setstoreto a custom directory to specify a path other than_targets/. The path need not exist before the pipeline begins, and it need not end with "_targets", but it must be writeable. For optimal performance, choose a storage location with fast read/write access. If the argumentNULL, the setting is not modified. Usetar_config_unset()to delete a setting.- stash_gitignore
Logical of length 1, whether to temporarily stash the
.gitignorefile of the data store. See the "Stashing .gitignore" section for details.- git_lfs
Logical, whether to automatically opt into Git LFS to track large files in
_targets/objectsmore efficiently. IfTRUEand Git LFS is installed, it should work automatically. IfFALSE, you can always opt in later by runninggit lfs track objectsinside the data store.- verbose
Logical of length 1, whether to print messages to the R console.
Details
tar_git_init() also writes a .gitattributes file to the
store to automatically track target output date with git-lfs
if it is installed on your system.
Stashing .gitignore
The targets package writes a .gitignore file to new data stores
in order to prevent accidental commits to the code Git repository.
Unfortunately, for gittargets, this automatic .gitignore file
interferes with proper data versioning. So by default, gittargets
temporarily stashes it to a hidden file called .gittargets_gitignore
inside the data store. If your R program crashes while the stash
is active, you can simply move it manually back to .gitignore
or run tar_git_status_data() to restore the stash automatically
if no .gitignore already exists.
See also
Other git:
tar_git_checkout(),
tar_git_log(),
tar_git_ok(),
tar_git_snapshot(),
tar_git_status_code(),
tar_git_status_data(),
tar_git_status_targets(),
tar_git_status()
Examples
if (Sys.getenv("TAR_EXAMPLES") == "true" && tar_git_ok(verbose = FALSE)) {
targets::tar_dir({ # Containing code does not modify the user's file space.
targets::tar_script(tar_target(data, 1))
targets::tar_make()
tar_git_init()
})
}