Alfresco and version control using git (under construction)

Goals

  • Be able to share analysis reports and programs used to create reports on Alfresco
  • Allow multiple users to collaborate on analysis reports
  • Version control is a best programming practice. Use git for this purpose.
  • Simplicity

Preliminaries

  • These are Linux instructions
  • Set up WebDAV to mount the network file system as detailed in AlfrescoNotes#WebDAV
  • After git, Alfresco, and WebDAV are ready
    • If you need to move a current project on your local computer to Alfresco, start at Step 1.1
    • If you already have a project on Alfresco and you want to add version control with git, start at Step 1.2
    • If version control (git) has already been set up on your Alfresco, start at Step 2

Step 1: Copy files to Alfresco (if needed) and initialize the git repository

  • This step needs to be done by one collaborator for each project. If the project has already be set up using git on Aflresco, then you can skip to step 2.
  • The following notes refer to a project for Dr Anani within the neonatology collaboration plan. The current analysis for the anani project are located on my computer. I want to move all files to Alfresco and set up a git repository on the server. I use the FolderOrg structure for projects. On my computer, this directory structure from my home directory for this project looks like the following
|-- projects                      # perhaps the most important dir
|   |-- neonatology                # organize by major area, within this 
|   |   |-- anani               #  have a folder for each project; sometimes
|   |   |   |-- R                  #  have a directory for each PI
|   |   |   |-- data                  #  within a project, I always have a 'data' and 'R' directory; others as neeeded
|   |   ...
. . .
  • After completing AlfrescoNotes#WebDAV, my directory structure for Alfresco is similar but not identical
|-- alfresco
|   |-- Sites 
|   |   |-- neonatology
|   |   |   |--documentLibrary
|   |   |   |   |-- anani
|   |   |   |   |   |-- R
|   |   |   |   |   |-- data
. . .

Step 1.1 Copy analysis files from my computer to the Alfresco server (if necessary)

cd ~/projects/neonatology/anani
rsync -av * ~/alfresco/Sites/neonatology/documentLibrary/anani/

Step 1.2 Initialize the git repository on Alfresco server

cd ~/alfresco/Sites/neonatology/documentLibrary
git init
git add .
git commit -m "Initial"
git config --local receive.denyCurrentBranch updateInstead
  • Note that the I found that 'git config' was necessary to run one time in order for push and pull to work (below). More details are found here.

Step 2: Workflow using Alfresco (with WebDAV) and git

Option 1: Work directly on the Alfresco server with WebDAV
  • This option is simpler as you only have to commit changes as with usual version control. However, it is slower and less flexible.
  • The important git commands for adding files and committing changes are
cd ~/alfresco/Sites/<collaboration>/documentLibrary/<project>
... # Make all of your changes to the analysis, add datasets, etc.
git add .
git commit -m "<your descriptive name>"
Option 2: Work locally on your computer
  • This option requires cloning the repository (one time), adding and committing changes, and pushing local changes to the server.
Cloning (first time) or pulling (following times)
  • To clone the project from Alfresco
cd ~/projects/neonatology/
git clone ~/alfresco/Sites/neonatology/documentLibrary/anani
  • Cloning from Alfresco to local only needs to happen once. However, if collaborators made changes (and committed and pushed those changes) on the server, you will want to pull those updates to your local copy before starting your update.
cd ~/projects/neonatology/
git pull anani
Add, commit, push (every time)
  • After making changes such as altering the R program or adding data, those changes must be committed and then pushed back to the Aflresco server. Committing saves the changes locally, pushing transfers the changes to Alfresco so your collaborators will see the changes as well.
git add .
git commit -m "<your descriptive name>"
git push

Tips

  • Within you R files, use relative rather than absolute paths that will work on either your local or Alfresco file system (eg '../data/myscript.R' rather than '~/projects/neonatology/anani/data/myscript.R')
  • A GIT cheat sheet covering more commands than I give here

-- ChrisSlaughter - 03 Oct 2017

This topic: Main > TWikiUsers > ChrisSlaughter > AlfrescoGit
Topic revision: 04 Oct 2017, ChrisSlaughter
 
This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback