%%{init: { 'theme': 'base', 'sequence': {'showSequenceNumbers': true}} }%%
sequenceDiagram
participant Workspace
participant Staging Area (index)
participant Local Repository
participant Remote Repository
note over Remote Repository: ๐ Hosted Online
rect rgb(235, 242, 240)
opt Work on scripts locally and send to remote
Workspace->>Staging Area (index): git add
note right of Workspace: Prepares contents for commit
note right of Staging Area (index): Records changes to the repository
Staging Area (index)->>Local Repository: git commit
note right of Local Repository: Upload local content to remote
Local Repository->>Remote Repository: git push
end
end
rect rgb(252, 243, 248)
alt Fetch changes from remote then merge with local
note right of Local Repository: ๏ธDownloads refs and objects
Remote Repository->>Local Repository: git fetch
note right of Workspace: Incorporate changes
Local Repository->>Workspace: git merge
else or do fetch & merge at once
note right of Workspace: Downloads and incorporate changes
Remote Repository->>Workspace: git pull
end
end
Gitlab workflows
Showcasing different scenarios
Here we present different scenarios in which researchers can use Git
An overview of Git
This diagram summarizes the basic steps for using Git. We can perform these steps using the command line or using a program with a Graphic User Interface.
Workflows in a single project
Here we describe several scenarios in which there are several researchers working on separate analyses or features within the same project. They use the same source data but their scripts are independent. We assume that each researcher is the main contributor to a set of scripts for a given analysis, study or experiment within the main project.
Multiple repositories
- All project-related
- The scripts subfolder is a clone of a remote repository
- Each researcher manages a subfolder within the repository and pushes/commit changes within that folder
Pros, Cons & Warnings
โ ๏ธ The different repositories should be preferably under a common git group/user, namely , the labโs Gitlab or Github.
โ ๏ธ Researchers may keep their local clones in their personal folders (outside project: see example 2). In this case their internal collaborators or principal investigator will only be able to see their scripts through the repository , so changes should be committed regularly.
๐ป If there are many users and analyses this can result in many repositories associated to a project
Folder tree
Example 1
Project/ NAS folder accessible to all researchers
โโ data
โโ outputs
โโ scripts
โ โโ researcher1* [Cloned Git repository 1] ๐
โ โโ researcher2 [Cloned Git repository 2] ๐
โโ ..
*subfolders may be named by analysis, experiment or study within the projectExample 2
Project/ NAS folder accessible to all researchers
โโ data
โโ outputs
โโ ..
researcher1/ Location may differ from that of the project
โโ scripts [Cloned Git repository 1] ๐
researcher2/
โโ scripts [Cloned Git repository 2] ๐Workflow
Each researcher has completely independent repositories. Researchers may edit and create code directly in the main branch or creating development branches and then merging with the main.
Repository 1
%%{init: { 'theme': 'base', 'gitGraph': {'showBranches': true,'showCommitLabel': false}} }%%
gitGraph
commit
commit
branch branch1
commit
commit
checkout main
merge branch1
commit
Repository 2
%%{init: { 'theme': 'base', 'gitGraph': {'showBranches': true,'showCommitLabel': false}} }%%
gitGraph
commit
commit
branch branch1
commit
commit
checkout main
merge branch1
commit
A single repository
- All project-related files in one location accessible by all contributing researchers
- The scripts project subfolder is a clone of a remote repository
- Each researcher manages a subfolder within the repository and pushes/commit changes within that folder
Pros, Cons & Warnings
๐ปRisk of accidental interference with colleagueโs changes
๐ปYou canโt share or manage access to only one researcherโs scripts
โ ๏ธ Researchers need to make sure they push and commit only their changes in their subfolders
โ ๏ธNote that naming script subfolders by author is not informative and can work for a project in development, but not for publishing (sharing with external collaborators)
Folder tree
#| code-overflow: wrap
Project/ ~NAS folder accessible to all researchers~
โโ data
โโ outputs
โโ scripts* [Cloned Git repository] ๐
โ โโ researcher1
โ โโ researcher2
โโ ..
*subfolders may be named by analysis, experiment or study within the projectWorkflow
The different researchers access the project folder and work within their folder. When they are done they and push their changes and commit them to the main branch of the projectโs repository
%%{init: { 'theme': 'base', 'gitGraph': {'showBranches': true,'showCommitLabel': false}} }%%
gitGraph
commit
commit
branch researcher1
commit
commit
checkout main
branch researcher2
commit
commit
checkout main
merge researcher1
merge researcher2
commit