Work in Progress
This page is a work in progress. If you have notes/hints/tips on DSpace development with Git/GitHub, please feel free to suggest their addition, or even add them to this page directly.
DSpace on GitHub
The DSpace GitHub code repository can be found at: https://github.com/DSpace/DSpace
A list of some possibly useful external Git resources:
(Feel free to add to the list)
- Intro to Git for those who know SVN: http://git.or.cz/course/svn.html
- Pro-Git Book (Online):
- Git Community Book (Online):
- Git Reference: http://gitref.org/
- Fedora Developers' list of useful Git Resources
- Fedora Developers' Git Guidelines and Best Practices (not all are Fedora specific)
- Fedora Developers' Git Quick Start Guide
- Chris Wilper's (Fedora Committer) tips/rules on using Git: https://wiki.duraspace.org/display/~cwilper/How+I+Use+Git
Still want to use SVN locally, even though DSpace is on GitHub?
- GitHub does provide some basic SVN client support (e.g. SVN checkout): https://github.com/blog/966-improved-subversion-client-support
- Or, you could obviously download the zipped-up DSpace release packages and import them into your local SVN
Overview of the Git Lifecycle
(Borrowed from Fedora's Git Guidelines and Best Practices)
Git allows a developer to copy a remote subversion repository to a local instance on their workstation, do all their work and commits in that local repository, then push the state of that repository back to a central facility (github).
Bearing in mind that you will always being doing your work and commits locally, a typical session looks like this:
git clone email@example.com:DSpace/DSpace.git && cd dspace
Get a copy of the central storage facility (the repository).
git branch DS-123
Create a local branch called "DS-123".
git checkout DS-123
Create a local copy of the branch from master if it doesn't exist, make it your active working branch.
Now, start creating, editing files, testing. When you're ready to commit your changes:
git add [file]
This tells git that the file(s) should be added to the next commit. You'll need to do this on files you modify, also.
git commit [file]
Commit your changes locally.
Now, the magic:
git push origin DS-123
This command pushes the current state of your local repository, including all commits, up to github. Your work becomes part of the history of the DS-123 branch on github.
git push is the command that changes the state of the remote code branch. Nothing you do locally will have any affect outside your workstation until you
push your changes.
git pull is the command that brings your current local branch up-to-date with the state of the remote branch on github. Use this command when you want to make sure your local branch is all caught up with changes
push'ed to the remote branch.
Some useful Git terms
master: this is the main code branch, equivalent to trunk in Subversion. Branches are generally created off of master.
origin: the default remote repository that all your branches are
pull'ed from and
push'ed to. This is defined when you execute the initial
git clone command.
unpublished vs. published branches: an unpublished branch is a branch that only exists on your local workstation, in your local repository. Nobody but you know that branch exists. A published branch is one that has been
push'ed up to github, and is available for other developers to checkout and work on.
fast-forward: the process of bringing a branch up-to-date with another branch, by fast-forwarding the commits in one branch onto the other. For more information, see Pro-Git's chapter on "Basic Branching & Merging"
rebase: the process by which you cut off the changes made in your local branch, and graft them onto the end of another branch. For more information, see Pro-Git's chapter on Rebasing and GitHub's 'rebase' page.
Some useful Git Development Guidelines
The DSpace Developers/Committers are still working on our Git Guidelines & Best Practices.
But in the meantime, here's some development guidelines from a few "third parties" (feel free to add additional links)
- Very widely used & popular model: "A successful Git branching model" ('git-flow' branching model)
- There are also "git-flow" tools available at: https://github.com/nvie/gitflow These tools give you quick ways to create the various types of branches described in the above model (release / feature / hotfix branches)
- Chris Wilper's "How I Use Git" (Chris's perspective based off the above "gitflow" model)
- Fedora Developers' Git Guidelines and Best Practices (not all are Fedora specific) - this is how they approach development in Git
Getting Started with DSpace + Git
Clone the repository. (The git repo is ~65MB)
At this point, you now have a copy of the DSpace Source Code, and you are checked out to the branch
master (master is akin to svn trunk), which will work, but it is the bleeding edge of development and not recommended for production instances.
If you would like to develop on DSpace for your local needs (University, Library, or Institution), you are encouraged to fork this repository, and commit your changes to your personal/organizational repository. We recommend that you build your repository off of a released "tag" of DSpace such as
dspace-1.8.2. The benefit of being based off of a tag/release-branch is that releases have a series of testing phases to ensure high quality, and there is some maintenance of bug and security fixes.
From there, the standard DSpace build instructions follows.
Quick Primer on Using Git
Checking the status of your tree.
Looking at the difference of your work in progress.
Commit your changes to your local tree.
git commit NameOfFileToCommit.java
Update your tree to get all the changes pushed to this central Git Repository.
If you would like to update your local checkout, for instance before sending a pull request for your local changes,
git rebase is the tool you will use, e.g.
git rebase master
At this point, if you have any conflicts between your local changes and the latest changes on GitHub, git will prompt you to resolve these conflicts.
If you have any questions contact the DSpace community either on IRC, or on the dspace-devel mailing list.
Contributing Changes/Patches to DSpace via GitHub
While we're still working out the ideal workflow for contributions, existing Committers will have direct push access to the DSpace GitHub repo, while contributors are encouraged to submit a Pull Request for review.
A few notes on creating a proper "Pull Request"
- Please, make sure to create a "Pull Request" from a branch and NOT from your "master". (You'll understand exactly why after reading #2)
- Be warned that any additional changes/commits you make to that branch (before the "Pull Request" is accepted/merged) will immediately be included in that existing "Pull Request". This means that, if you want to continue your local development, you must create that "Pull Request" from a semi-static branch (so that any additional commits you make on "master" in the meantime don't get included as part of the existing "Pull Request").
- The reason why this occurs is that a "Pull Request" just points at a specific "branch" (the branch it was initialized from). It does NOT point at a specific set of commits. So, when the "Pull Request" is accepted/merged, you are pulling in the latest version of that "branch". For more information, closely read the GitHub help page on Pull Requests
- Once your "Pull Request" is created, you can use the GitHub Pull Request tools to communicate with the Committer who is assigned to the Pull Request. If further changes are requested, you can make those changes on the branch where you initiated the Pull Request (and those changes will automatically become part of the Pull Request, as described above)