|
Size: 4578
Comment:
|
Size: 7440
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| #acl LcnGroup:read,write,delete,revert All: | #acl LcnGroup:read,write,delete,revert All:read <<TableOfContents>> This page describes how one would go about contributing changes to the freesurfer source code repository on github. The official freesurfer source code repository can be found on the page: https://github.com/freesurfer/freesurfer == Initial Setup == The initial setup for contributing to the freesurfer repository involves the user forking off the freesurfer !GitHub repo, cloning the users fork into a local repository, then adding the freesurfer repository as an upstream remote. This setup is illustrated below, followed by a more detailed description of the steps involved: {{attachment:github_workflow6.jpeg}} 1. Sign up for a [[https://github.com/|github]] account if you don't already have one. When creating an account, you can use any email you want, but developers at the Martinos Center should eventually link their <username>@mgh.harvard.edu email to their !GitHub account. This can be done after the account is created. 2. From your !GitHub account, fork the [[https://github.com/freesurfer/freesurfer|freesurfer project repository]] by clicking on the 'Fork' button near the top right-hand of the page. This creates a copy of the freesurfer code base under your account on the !GitHub server. {{attachment:fork.jpeg}} 3. On your local machine, make a clone of your freesurfer repository (the one you forked): {{{ git clone git@github.com:<git_username>/freesurfer.git }}} 4. Add the main freesurfer repository as a remote to the local clone you already have on your local disk, and set it as the '''upstream''' remote: {{{ git remote add upstream git@github.com:freesurfer/freesurfer.git }}} 5. Type the following command to make sure you have the proper setup: {{{ git remote -v origin git@github.com:zkaufman/freesurfer.git (fetch) origin git@github.com:zkaufman/freesurfer.git (push) upstream git@github.com:freesurfer/freesurfer.git (fetch) upstream git@github.com:freesurfer/freesurfer.git (push) }}} == Committing Changes == To contribute the the freesurfer code base, users should create a new branch off the {{{dev}}} branch, push the branch to their fork ({{{origin}}}), then submit '''Pull requests''' into {{{freesurfer/dev}}} to get those changes into the freesurfer code base. This workflow is illustrated below, followed by a more detailed description of the steps involved: {{attachment:github_workflow5.JPG}} 1. When you start to make changes, the first thing to do is make sure you are in the dev branch and everything is up to date with the upstream repo: {{{ git branch * dev }}} {{{ git pull upstream dev }}} 2. Then create a new branch (off {{{dev}}}) to hold your work and start making changes. Ideally, use a prefix signaling the purpose of the branch: {{{ git checkout -b nf-my-feature }}} * {{{nf-}}} for new features * {{{bf-}}} for bug fixes * {{{rf-}}} for refactoring * {{{doc-}}} for documentations contributions. * {{{test-}}} for test related contributions. 3. Work on this copy on your computer using Git to do the version control. When you're done editing, commit the files to the local branch and push the branch to {{{origin}}} (your personal !GitHub account): {{{ git add <modified_files> git commit -m "Commit message" git push origin nf-my-feature }}} 4. Finally, go to the !GitHub web page of your fork of the freesurfer repo, and click '''Pull request''' to send your changes to the maintainers for review. Make sure you are submitting your newly created branch into the {{{freesurfer/dev}}}. This will send an email to the committers. You can commit new changes to this branch and keep pushing to your remote -- github automagically adds them to your previously opened Pull request. |
| Line 4: | Line 83: |
| This page is provided for !FreeSurfer developers to assist in the CVS -> git transition. This page is not meant to be a comprehensive guide for using git. Git is a feature loaded version control system which at times can be a bit of a hurdle to learn. The following site However, when used in its simplest form it is very similar to most all other version control systems, including CVS. Below are many of the basic CVS commands used by !FreeSurfer developers the git equivalent of that command. The [[https://www.atlassian.com/git/tutorials/what-is-git|Atlassian]] and [[https://git-scm.com/doc|git-scm]] are great resources for those who want to dig deeper and and learn more about git and its features. |
{{attachment:new_pull_request.JPG}} |
| Line 9: | Line 86: |
| == Initial Git Setup == | {{attachment:compare_changes.jpeg}} |
| Line 11: | Line 88: |
| When we start out using git we want to set a few of our configuration settings. We only need to do this one time: {{{ $> cd ~ $> git config --global user.name "Zeke Kaufman" $> git config --global user.email zkaufman@nmr.mgh.harvard.edu }}} For additional examples of git specifics setting (e.g. default editor, color settings), see the following page: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration |
5. Once you have submitted your pull request for the {{{nf-my-feature}}}, it is best practice to switch back into {{{dev}}} and do an update. You are then free to start the process anew (i.e. create a new branch, commit changes, submit pull request): |
| Line 19: | Line 90: |
| == Checkout out the main branch == | {{{ git checkout dev git pull upstream dev }}} === Cleanup steps (Optional) === 6. Once your pull request is accepted (you should get an email), feel free to delete the branch you created: {{{ git branch -D nf-my-feature }}} == Developing == Instructions on how to further work with the freesurfer source code, including building, testing, and adding a binary to the tree, should consult the Freesurfer Developers Guide: https://surfer.nmr.mgh.harvard.edu/fswiki/DevelopersGuide_git == Data files == Data files represent a special case for source code repositories and generally speaking data files should not be stored in a source code repo. Rather they should be stored in a separate storage area, reserved for times when retrieval is required (e.g. updating test data, performing local installations, etc). Think of "source code" as files which are made up of text, are required for compilation, and can be easily inspected by the human eye (and diff'ed by the '''diff''' program). Think of "data files" as files stored as binary and not required for compilation. A default clone of the repo will only give the user source code. Data files are stored in git annex, exist as broken symlinks by default, and need to be specially requested. To request a datafile, first add the remote repository that stores all the freesurfer data files: {{{ (Users outside the Center) git remote add datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git git fetch datasrc (Users within the Center) git remote add datasrc file:///space/freesurfer/repo/annex.git git fetch datasrc }}} Your list of remote repositories should now look something like this: {{{ git remote -v datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git (fetch) datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git (push) origin git@github.com:zkaufman/freesurfer.git (fetch) origin git@github.com:zkaufman/freesurfer.git (push) upstream git@github.com:freesurfer/freesurfer.git (fetch) upstream git@github.com:freesurfer/freesurfer.git (push) }}} Then you can just specifically request whatever datafile you need: {{{ git annex get GEMS2/Testing/test.txt.gz ######################################################################## 100.0% (checksum...) ok (recording state in git...) }}} Or just get everything (Not recommended): {{{ git annex get . }}} |
| Line 23: | Line 157: |
| ## This page is provided for !FreeSurfer developers to assist in the CVS -> git transition. | |
| Line 24: | Line 159: |
| When working with CVS, we would checkout out the !FreeSurfer repository using the '''{{{cvs checkout dev}}}''' command. In git we 'clone' repositories. This gives us a local version of the repository which we can work with: {{{ $> git clone /space/freesurfer/repo/freesurfer }}} |
##This page is not meant to be a comprehensive guide for using git. Git is a feature loaded version control system which at times can be a bit of a hurdle to learn. However, when used in its simplest form, it can be very similar to most all other version control systems, including CVS. Below are many of the basic CVS commands used by !FreeSurfer developers the git equivalent of that command. |
| Line 29: | Line 161: |
| ##The following sites are great resources for those who want to dig deeper and and learn more about git and its features. | |
| Line 30: | Line 163: |
If you wanted to check out a specific branch, you could do that in a couple different ways: {{{ $> git clone /space/freesurfer/repo/freesurfer $> cd freesurfer $> git checkout stable6 or, $> git clone -b stable6 /space/freesurfer/repo/freesurfer }}} Additional information and examples: [[https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository|Cloning-an-Existing-Repository]] [[https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone|git-clone]] == Daily Workflow == === Updating your code === In CVS, when we want the most up-to-date version of the code, we issue a '''{{{cvs update}}}''' command. This will update our files to the latest version, restore any missing files, and warn us of any conflicts. The nearest equivalent in git is the '''{{{git pull}}}''' command. This will update our local repository and update all the necessary files to the most recent version. ''It is good practice to always issue a '''{{{git pull}}}''' command before starting to work on any files.'' {{{ $> git pull }}} One major difference between '''{{{cvs update}}}''' and '''{{{git pull}}}''' command is that '''{{{git pull}}}''' will not restore any missing files (i.e. files that we deleted locally). In git, if we want to restore locally deleted files, we need to take the additional step of issuing a '''{{{git checkout}}}''' command. For example: {{{ $> rm README $> git pull $> git status deleted: README.txt $> git checkout README.txt }}} Additional information and examples: [[https://www.atlassian.com/git/tutorials/syncing/git-pull|git-pull]] === Commit a modified source code file === Git and CVS can be virtually identical when it comes to committing changes. The primary difference is that git requires the additional step of pushing to the central repository. You always need to issue a ||'''cvs'''||{{{cvs commit -m "Added new capabilities." <file_name>}}}|| ||<|2>'''git'''||{{{git commit -m "Added new capabilities." <file_name>}}}|| ||{{{git push}}}|| Modify and commit a data file: ||'''cvs'''||{{{cvs commit <file_name>}}}|| ||<|5>'''git'''||{{{git annex unlock <file_name>}}}|| ||{{{git annex add <file_name>}}}|| ||{{{git commit <file_name>}}}|| ||{{{git push}}}|| ||{{{git annex copy --to origin <file_name>}}}|| Add a data file: ||<|2>'''cvs'''||{{{cvs add <file_name>}}}|| ||{{{cvs commit <file_name>}}}|| ||<|4>'''git'''||{{{git annex add <file_name>}}}|| ||{{{git commit <file_name>}}}|| ||{{{git push}}}|| ||{{{git annex copy --to origin <file_name>}}}|| Remove data file: ||<|3>'''cvs'''||{{{rm <file_name>}}}|| ||{{{cvs rm <file_name>}}}|| ||{{{cvs commit -m "Removing <file_name>" <file_name>}}}|| ||<|2>'''git'''||{{{git rm <file_name>}}}|| ||{{{git commit -m "Removing <file_name>" <file_name>}}}|| Undo 1 commit (before push): ||'''git'''||{{{git reset --soft HEAD~1}}}|| Undo 2 commits: ||'''git'''||{{{git reset --soft HEAD~2}}}|| |
## * [[https://www.atlassian.com/git/tutorials/what-is-git|Atlassian]] ## * [[https://git-scm.com/doc|git-scm]] |
This page describes how one would go about contributing changes to the freesurfer source code repository on github. The official freesurfer source code repository can be found on the page:
Initial Setup
The initial setup for contributing to the freesurfer repository involves the user forking off the freesurfer GitHub repo, cloning the users fork into a local repository, then adding the freesurfer repository as an upstream remote. This setup is illustrated below, followed by a more detailed description of the steps involved:
Sign up for a github account if you don't already have one. When creating an account, you can use any email you want, but developers at the Martinos Center should eventually link their <username>@mgh.harvard.edu email to their GitHub account. This can be done after the account is created.
From your GitHub account, fork the freesurfer project repository by clicking on the 'Fork' button near the top right-hand of the page. This creates a copy of the freesurfer code base under your account on the GitHub server.
- On your local machine, make a clone of your freesurfer repository (the one you forked):
git clone git@github.com:<git_username>/freesurfer.git
Add the main freesurfer repository as a remote to the local clone you already have on your local disk, and set it as the upstream remote:
git remote add upstream git@github.com:freesurfer/freesurfer.git
- Type the following command to make sure you have the proper setup:
git remote -v origin git@github.com:zkaufman/freesurfer.git (fetch) origin git@github.com:zkaufman/freesurfer.git (push) upstream git@github.com:freesurfer/freesurfer.git (fetch) upstream git@github.com:freesurfer/freesurfer.git (push)
Committing Changes
To contribute the the freesurfer code base, users should create a new branch off the dev branch, push the branch to their fork (origin), then submit Pull requests into freesurfer/dev to get those changes into the freesurfer code base. This workflow is illustrated below, followed by a more detailed description of the steps involved:
- When you start to make changes, the first thing to do is make sure you are in the dev branch and everything is up to date with the upstream repo:
git branch * dev
git pull upstream dev
Then create a new branch (off dev) to hold your work and start making changes. Ideally, use a prefix signaling the purpose of the branch:
git checkout -b nf-my-feature
nf- for new features
bf- for bug fixes
rf- for refactoring
doc- for documentations contributions.
test- for test related contributions.
Work on this copy on your computer using Git to do the version control. When you're done editing, commit the files to the local branch and push the branch to origin (your personal GitHub account):
git add <modified_files> git commit -m "Commit message" git push origin nf-my-feature
Finally, go to the GitHub web page of your fork of the freesurfer repo, and click Pull request to send your changes to the maintainers for review. Make sure you are submitting your newly created branch into the freesurfer/dev. This will send an email to the committers. You can commit new changes to this branch and keep pushing to your remote -- github automagically adds them to your previously opened Pull request.
Once you have submitted your pull request for the nf-my-feature, it is best practice to switch back into dev and do an update. You are then free to start the process anew (i.e. create a new branch, commit changes, submit pull request):
git checkout dev git pull upstream dev
Cleanup steps (Optional)
- Once your pull request is accepted (you should get an email), feel free to delete the branch you created:
git branch -D nf-my-feature
Developing
Instructions on how to further work with the freesurfer source code, including building, testing, and adding a binary to the tree, should consult the Freesurfer Developers Guide:
Data files
Data files represent a special case for source code repositories and generally speaking data files should not be stored in a source code repo. Rather they should be stored in a separate storage area, reserved for times when retrieval is required (e.g. updating test data, performing local installations, etc). Think of "source code" as files which are made up of text, are required for compilation, and can be easily inspected by the human eye (and diff'ed by the diff program). Think of "data files" as files stored as binary and not required for compilation.
A default clone of the repo will only give the user source code. Data files are stored in git annex, exist as broken symlinks by default, and need to be specially requested. To request a datafile, first add the remote repository that stores all the freesurfer data files:
(Users outside the Center) git remote add datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git git fetch datasrc (Users within the Center) git remote add datasrc file:///space/freesurfer/repo/annex.git git fetch datasrc
Your list of remote repositories should now look something like this:
git remote -v datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git (fetch) datasrc https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git (push) origin git@github.com:zkaufman/freesurfer.git (fetch) origin git@github.com:zkaufman/freesurfer.git (push) upstream git@github.com:freesurfer/freesurfer.git (fetch) upstream git@github.com:freesurfer/freesurfer.git (push)
Then you can just specifically request whatever datafile you need:
git annex get GEMS2/Testing/test.txt.gz ######################################################################## 100.0% (checksum...) ok (recording state in git...)
Or just get everything (Not recommended):
git annex get .
