Working with Git

Ryan Schmidt ryandesign at macports.org
Wed Nov 2 20:24:29 PDT 2016


> On Oct 31, 2016, at 12:04 PM, Lawrence Velázquez <larryv at macports.org> wrote:
> 
>> On Oct 31, 2016, at 11:29 AM, Ryan Schmidt <ryandesign at macports.org> wrote:
>> 
>>> On Oct 5, 2016, at 9:53 PM, Ryan Schmidt <ryandesign at macports.org> wrote:
>>> 
>>> How will this work on GitHub?
>>> 
>>> The user will submit a pull request. How do I test it locally? What if the pull request is incomplete? I know I can tell the user what's wrong, and they can push another commit to the same branch they made to initiate the pull request, and those new commits will automatically appear in the pull request, and I can then merge it if I like it. But what if the user does not respond and fix the changes? What if the user makes additional commits but they're still not sufficient? How do I take the user's pull request, make additional changes, and commit them to our master?
>> 
>> There were several different and sometimes conflicting answers to this question in this thread. Now that we have converted to git, and I have received a pull request for one of my ports, I need to know how to test it locally and then commit it to master. I don't want to understand git's theory or to be given lots of options amongst which to choose; I just want to be told how to get my work done.
> 
> Here are some rough instructions. These will have to be refined; let me
> know if you have any problems. I'm writing this in a bit of
> a sleep-deprived fog.
> 
> To the right of the big green "Rebase and merge" button on the PR page,
> you should see a link to view "command line instructions". Those
> instructions are almost what you want, but you'll have to tweak them to
> avoid merge commits.

Yes, there are "command line instructions" on the web site, but they are different from the commands you gave below, which are again different from other commands suggested in previous threads, so it is difficult to know which set of instructions to follow.


> To obtain the submitter's changes:
> 
> 	$ git fetch https://github.com/l2dy/macports-ports.git curl-ca-bundle-update
> 	$ git checkout -b l2dy-curl-ca-bundle-update FETCH_HEAD
> 	$ git rebase master l2dy-curl-ca-bundle-update
> 
> The first command imports changes from the submitter's
> "curl-ca-bundle-update" branch. The second command creates a new local
> branch to match. The third command transplants the submitter's changes
> onto the top of your master branch. (Rebasing will fail if the
> submitter's changes don't apply cleanly to the current ports tree. You
> can just ask them to fix this themselves and push a new branch.)
> 
> Now you can check out the new branch and try out the submitter's
> changes. You can also modify the branch as you see fit.
> 
> 	$ git checkout l2dy-curl-ca-bundle-update
> 
> When you're ready to push the submitter's contributions to master:
> 
> 	$ git checkout master
> 	$ git merge --ff-only l2dy-curl-ca-bundle-update
> 	$ git push origin master

Thanks, that worked, up until the "git push origin master" command, which asked me to authenticate, and supplying my username and password was unsuccessful:

$ git push origin master
Username for 'https://github.com': ryandesign
Password for 'https://ryandesign@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/macports/macports-ports.git/'

Instead, I used GitHub Desktop's "Sync" button, which worked. I usually prefer to use GitHub Desktop, but it would be nice to be able to push from the command line as well.

> The first two commands incorporate the submitter's changes into your
> master branch. The last one pushes to GitHub.

Now I still seem to have this branch in my local git repo:

$ git branch
  l2dy-curl-ca-bundle-update
* master

Can I delete it? With, I presume, "git branch -d l2dy-curl-ca-bundle-update"?


>> Could someone please update the WorkingWithGit page with the correct instructions?
> 
> Yes, I will polish up that page this week, as well as the migration FAQ.



More information about the macports-dev mailing list