(^1) Institute for Integrative Biology of the Cell (I2BC) UMR 9198, Universit ́e Paris-Sud, CNRS, CEA 91190 - Gif-sur-Yvette, France (^2) IFB Core Cluster taskforce
“Most researchers are primarily collaborating with themselves,” Tracy Teal explains. “So, we teach it from the perspective of being helpful to a ‘future you’.”
”Rule 4: Version Control All Custom Scripts”
version control, revision control, source control, or source code management: class of systems responsible for managing changes to files.
Each revision is associated with a timestamp and the person making the change. Revisions can be compared, restored, and merged.
git config --global user.name <Your Name>
git config --global user.email <Your Email>
The initialisation (red arrow) is the creation of a .git repository:
3 ways to initialize a .git repository:
# inside an existing folder (possibly containing files)
git init
# create the folder ”myproject” + initializes the .git subfolder inside it
git init <myproject>
# copy the existing git repository to
git clone </gitfolder/path> </new/path>
git add and then commit commands for myfile.txt :
git add <myfile.txt>
git commit -m <"my reason">
Checking the file status:
git status
File goes from untracked to tracked state (init), unstaged to staged state (add) and finally, to a committed state (commit).
docker run -i -t -v "${PWD}":/data continuumio/miniconda
Global configuration (checkinguser.namewith:git config –list):
git config --global user.name ’Your Name’
git config --global user.email ’Your Email’
On a new dedicated folder run:
git init # observe the .git folder (ls -la)
git status # find the current branch , "nothing to commit"
for i in 1 2 ; do echo "file"${i}" text" > file${i}.txt ;
done
git status # observe list of untracked files
git add file1.txt
git status # observe the changing status of file1: untracked => staged
sed ’s/text/text change/’ file1.txt > tmp ; mv tmp file1.txt
git status # observe the 3 states , why file1 appears in "to be commited" and also in "not staged for commit "?
git add file1.txt file2.txt # all files
git status
git commit -m "1st commit + file1 change" # always add a message , use present time to explain the change
git status # all ok
So far, we have initiated a new project whose code is versioned by git: we have created files and all their successive changes were saved thanks to git.
We will now create a 2nd project by copying an already existing one. We’re going to bring this project from an online git project site,e.g. github.
To download a project from github, we use the gitclonecommand:
git clone https :// github.com/clairetn/FAIR_bioinfo_github.git
### observe result
* a new folder has been created (check with the shelllscommand)
* its name is directly deduced from the url used
* this FAIR_bioinfo_githubfolder contains a.gitrepository and also aREADME.mdfile (see withls -la FAIR_bioinfo_github/)
* it is a minimal project!
## branching: objective 6
We plan to change the README file by adding our firstname at the authors list. With a git versioning system, a good practice is to create a branch to reserve the initial code until we validate our change.
### create a branch nammed ”branch1”
cd FAIR_bioinfo_github git branch branch
### list all branches
git branch # find the star
## branching: objective 6
### go into the new ”branch1”
git checkout branch git branch # find the star git status # find the branch
### work inot branch: change a file and keep change
Edit theREADME.mdfile and add your firstname to the ”Authors list”
git status # file README.md is modified git add README.md ; git commit -m “add my firstname in branch1”
git checkout master
more README.md # Is README.md modified or initial version?
We have check that our change is valid, so we now plan to move it into the master branch.
git merge branch
more README.md # what README.md version?
git branch -d branch1 # -d for delete
See: Careers’ paragraph, you’ll see a ”company” word