Working as part of a large team on a sizeable number of applications, it's fair to say that I spend quite a lot of time thinking about Git. After spotting a recent Railscast on open source contributions, it occurred to me that the process involved in maintaining an open source fork isn't neccessarily obvious. As a result, I've released give, a gem which wraps up some simple git workflow alongside the GitHub API, with the aim of making it just a little bit easier to get started contributing to open source projects.
The setup
gem install give
give
only requires that a GitHub user and token are set, you can check this by looking in ~/.gitconfig
or from the command line
git config --get github.user
git config --get github.token
If either are missing, this GitHub article will walk you throug the process.
With give
installed you can now fork a GitHub repository from the command line using the give setup USERNAME REPO
command. This example will fork the give
project from the user seenmyfate
give setup seenmyfate give
This command uses the GitHub API to fork the project you have specified to your GitHub account, and then clones your fork to your current path. An extra remote 'upstream' is also added to the project, pointing back to original project.
Staying current
Once you're ready to start coding, the give start BRANCH
command will create and checkout a new branch to work in
give start feature/my_awesome_feature
To be sure you're working on the latest code, the give update BRANCH
command will rebase your fork's master branch from the original repository, and then rebase your feature branch.
give update feature/my_awesome_feature
By doing this regularly you can be sure that you are not duplicating work, and also ensure that any code you depend on has not changed since you started work. This should also help your pull request to apply cleanly, allowing the project maintainer to easily pull in your contribution.
Pull
When your contribution is complete, push your changes to GitHub and send a pull request with give finish
. Here you must pass in the user and repository to send the pull request, and your local branch.
give finish seenmyfate give feature/my_awesome_feature
You will be prompted to enter a title and body for the pull request.
And that's it. I hope this gem will encourage more people to make their first open source contribution, and maybe make things a little easier for those who don't spend all day merging and rebasing with git. I'd love to hear from anyone having success with give
, and of course if you have any ideas for improvements, please fork away!