-
Notifications
You must be signed in to change notification settings - Fork 74
Getting started for new developers
- Talk to Ramon or Darryl, or email [email protected].
- Linux users: git command line client.
- Windows users: Git for Windows (command line and GUI) or TortoiseGit (GUI)
- Mac OSX users: git command line client.
You need to do this once per computer.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Different operating systems (Linux, Windows) deal with end-of-line differently. To make your system work correctly:
-
For Linux
git config --global core.autocrlf input git config --global core.safecrlf warn
-
For Windows
git config --global core.autocrlf true git config --global core.safecrlf warn
Run the following code replacing GITHUB_USERNAME by your github username
mkdir gerardus
cd gerardus
git init
git remote add origin https://[email protected]/vigente/gerardus
git pull origin master
git pull origin
With git, first you commit your changes locally, and then you push the commit to the repository. You can commit multiple times before a push.
-
Do some work. Add new files, or edit existing ones.
-
Add an entry to the ChangeLog file explaining the commit that you are about to make. For example:
2015-04-27 Ramon Casero <[email protected]> * matlab/ItkToolbox/elastix_bspline_grid.m: (0.1.3) - Fix bug. The displacement vector was being reshaped in the wrong way. Now it's first reshaped to the elastix grid size, and only then the rows and columns are swapped.
-
Stage the file(s) that you are going to commit together with the ChangeLog
git add ChangeLog newfunction.m anotherfunction.m
-
Commit the file(s), writing a meaningful log message (copy the one you put in the ChangeLog)
git commit origin master
-
You may want to do more commits (go back to step 2.).
-
Once you have done all the commits you want, push your changes onto the repository
git push origin master
Note: when you push code, you may be told that the repository has changed, and you no longer have the latest version of the code. In that case, you need to pull again and let git merge the repository with your local copy before pushing.
If you make a small change, you can work directly in master. But if you are going to be making changes over several days, and you don't want to break the project, you should create and work in a separate branch. This could be your own new branch, or maybe you are going to be working in somebody else's branch:
-
"Branch" the project, i.e. make a copy of the project that you can play with. For example, let's call the new branch "replace_scimat_min_by_offset"
git branch replace_scimat_min_by_offset
-
Switch from the master branch to the new branch
git checkout replace_scimat_min_by_offset
-
"Fetch" the project, i.e. update the information about the project branching
git fetch origin
-
Switch from the master branch to the new branch
git checkout replace_scimat_min_by_offset
-
Now make your changes, create new files, delete others, make several commits, push your changes to the respository, etc. This could take a few days.
-
Once you are done with all your changes, commits and pushes, switch back to the master branch
git checkout master
-
Merge the new branch with the master branch. This will put all your new stuff into the master branch
git merge replace_scimat_min_by_offset
-
If the merge went well, delete locally the branch you created, as it's no longer needed
git branch -d replace_scimat_min_by_offset
-
To delete the branch on the github server, you also have to run
git push origin --delete replace_scimat_min_by_offset
Basically, the papers directory is an orphan branch. This means that it lives outside of master, i.e. we are going to use a separate directory that is outside of "gerardus".
To clone it,
-
Create a directory in your computer for the papers, outside of the "gerardus" directory. Otherwise, it won't work because you'll have two separate branches overlapping.
mkdir papers-public cd papers-public git init git remote add origin https://github.com/vigente/gerardus git pull origin papers
-
Remember that when you commit and push in this directory, you use "papers" instead of "master" as the target branch.
- Here's a good short basic git tutorial
- Nice guided tour of git fundamentals
- A more extensive git course
- Advanced syntax for GitHub wikis (GitHub Favored Markdown)