How to contribute on github?

Jonathan M Davis jmdavisProg at gmx.com
Fri May 11 16:58:18 PDT 2012


On Saturday, May 12, 2012 00:34:45 Alex Rønne Petersen wrote:
> On 12-05-2012 00:22, Mehrdad wrote:
> > I haven't used git or github much. (Pretty much just once or twice, when
> > someone added me.)
> > 
> > How do I go about submitting potential changes to Phobos?
> > 
> > (All I see on there is "GIT Read-only" which I feel is read-only, not
> > something I can/know how to modify...)
> 
> OK, so what you do is you fork the Phobos repo. You then set up your
> local clone like so:
> 
> $ mkdir phobos
> $ cd phobos
> $ git init .
> $ git remote add upstream git at github.com:D-Programming-Language/phobos.git
> $ git remote add origin git at github.com:YourUserNameHere/phobos.git
> $ git fetch origin && git fetch upstream
> $ git checkout -b master origin/master
> 
> Now you have a working directory and a local master branch set up to
> track your fork's remote master branch.
> 
> Now you simply add commits to your repo, push them to GitHub (git push
> origin master), and send a pull request to the upstream Phobos repository.
> 
> Synchronizing with upstream can basically be done like so:
> 
> $ git fetch upstream
> $ git pull --rebase upstream master
> $ git push origin master -f
> 
> This fetches the latest changes from upstream, unrolls your fork's
> commits, adds in upstream's commits, then readds your fork's commits,
> and finally, force-pushes your local branch to your remote branch (the
> force push is necessary because you rewrite history, which is OK in your
> personal fork).

It works better if you just never do any work on the master branch and have 
the master branch match the main repository's master branch. Then you can 
always have up-to-date code which matches the actual code in the main 
repository, and it avoids any rebasing issues that you might have on your 
master branch (especially when your changes conflict with changes in the main 
repository). It also makes it easier to manage separate changes by having a 
branch for each. There's certainly nothing stopping you from doing work on 
your master branch, but it's generally more problematic to do so.

- Jonathan M Davis


More information about the Digitalmars-d mailing list