Working with Git

Rainer Müller raimue at macports.org
Thu Oct 6 10:58:15 PDT 2016


On 2016-10-06 09:33, Sterling Smith wrote:
> On Oct 5, 2016, at 7:53PM, Ryan Schmidt <ryandesign at macports.org> wrote:
> 
>> Suppose a user submits an update to a port.
>>
>> With Subversion, the user would submit a patch in a Trac ticket. To test it, I would download the patch and apply it to my local Subversion working copy. If I like it, I commit it. If I don't like it, I give feedback to the user in the ticket, or I edit the Portfile further and commit it, then tell the user in the ticket what changes I made.
>>
>> How will this work on GitHub?
>>
>> The user will submit a pull request. How do I test it locally?
> You test their changes by checking out their branch on your system.  Most likely they are on their own fork, and you will need to add their fork as a new remote
> 
> git remote add <name describing the fork> <path to fork>
> 
> before checking out their branch by issuing
> 
> git checkout <branch>  # Note that this can fail if more than one remote has the same branch name (such as master...), and there is a more verbose way to indicate from where to check out the branch

You will not need a new remote for this as GitHub will store a copy of
the branch submitted in the pull request in our repository.

Check the GitHub documentation here:

https://help.github.com/articles/checking-out-pull-requests-locally/#modifying-an-inactive-pull-request-locally


You can also use the hub [1] wrapper around git to make such things
easier. This tool implies all repository URLs will point to GitHub. For
example, the command
  hub remote add raimue/ports
would add a new remote named "raimue" with the URL for this repository
on GitHub.

Even better, many commands will just accept references to commits or
pull requests on GitHub. For example, you can directly switch to a local
checkout of a pull request with a single command:
  hub checkout https://github.com/macports/ports/pull/42
Also works similarly with 'hub cherry-pick' or 'hub am'.

Although I do not like their proposal to alias git to hub, as I like to
keep control what extensions I use with git. I prefer to explicitly call
hub when I want to work with GitHub.

Rainer

[1] https://hub.github.com/ ; 'sudo port install hub'


More information about the macports-dev mailing list