Code Version Control - CCP PET-MR · 2017-05-23 · Nomenclature Description git-speak Project/code...
Transcript of Code Version Control - CCP PET-MR · 2017-05-23 · Nomenclature Description git-speak Project/code...
gitCode Version Control
xkcd.com
Casper da Costa-Luis
(ex machine vision dev & resident git-guru @Sony)
PETMR Image Recon PhD Scholar @KCL
https://github.com/casperdcl
1
Version ctrl
Track changes for code over time
Revert to older versions easily
Collaborate efficiently
Merge conflicting code reliably
Or at least make it easy to manually do
2/20
3/20
4/20
5/20
Nomenclature
Description git-speak
Project/code database repository
Example of a website
hosting lots of projects
GitHub (https://github.com),
BitBucket (https://bitbucket.org)
Download a project clone
Mark changes to save stage
Save marked files/lines commit (repo <-> list of commits)
Download new changes pull
Fix conflicts [locally] merge (special type of commit)
Upload current state push
6/20
commit
A repository is essentially a list (network) of commits
Commits are permanent checkpoints
Must have a message
xkcd.com7/20
Large Projects have lots of:
Description git-speak
Developers authors
Users/nuisances watchers/stargazers
Code/versions/files commits
Official Versions tagged commits
Bugs/Feature requests issues
Minor spin-offs branches
Major spin-offs
(clone of entire repo)
fork
Suggestions to incorporate
spin-offs
merge/pull request (PR)
8/20
9/20
10/20
11/20
12/20
Contributions Strategy
Only one official, stable, up-to-date branch: master
Essentially “latest stable beta version with no known bugs
since last official release version”
Any work-in-progress commits should be in their own
branches
GitHub assigns a unique number to each issue
https://github.com/CCPPETMR/SIRF/issues
13/20
Contributions Strategy
A pull request (PR) is an issue with an associate branch
https://github.com/CCPPETMR/SIRF/pulls
Discussions on issues and PRs are forwarded [email protected] mailing list daily
Forwarded from github viahttps://groups.google.com/forum/#!forum/ccp-petmr-codebot,which is also a backup in case github dies
We prefer issues to be opened via github
Will never get lost in emails
Track status
Comments/discussion
Cross-reference related issues, PRs, and commits
Mailing list gets notified within 24 hours
14/20
15/20
Release Strategyreleasing a new official version
Must be a commit on master branch
Tag the commit using https://semver.org convention
vMajor.minor.patch(-extra)
Major: backward-incompatible
minor: new feature
patch: e.g. fix typo in documentation
v0.9.0-rc2 (Version 0.9.0 Release Candidate 2)
Add release notes
Describe changes since last release
16/20
17/20
git cheat sheetgit clone https://github.com/CCPPETMR/SIRF-SuperBuild
cd SIRF-SuperBuild
cmake . && make install
git pull && cmake . && make install # to update
git checkout –b mybranch # create new branch
git add myscript.m other/file.cpp
git commit –m “My cool changes”
git pull origin/master # optional
git push origin mybranch # first time needs an extra `-u`
https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf
Thre
e m
ost
use
d c
om
mands
in o
rder
of
pre
cedence
18/20
Conflicts and Diffs
19/20
GUIsgit: Git-GUI, gitk, SmartGit
diff: vimdiff, kdiff3, meld
Help a lot with (e.g.)
Avoiding commandline,
Visualising diffs
20/20