Working with Git

Rainer Müller raimue at macports.org
Thu Nov 3 19:29:43 PDT 2016


On 2016-11-04 02:48, Ryan Schmidt wrote:
> Your instructions and theirs already differ in the way in which the branch changes are obtained.
> 
> You said:
> 
>> 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
> 
> They say:
> 
>> Step 1: From your project repository, check out a new branch and test the changes.
>>
>> git checkout -b l2dy-curl-ca-bundle-update master
>> git pull https://github.com/l2dy/macports-ports.git curl-ca-bundle-update

Some things in git can be achieved with different commands. Whether you
first create a branch and then fetch a remote or vice-versa usually does
not matter.

While Larry's version ensures you will always do a rebase, the version
from GitHub could fall back to a merge. Assuming the 'git pull' results
in a fast-forward, both command sequences should be equivalent as far as
I can see.

>>> 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/'
>>
>> That's curious. What does "git remote -v" print?
> 
> $ git remote -v
> origin	https://github.com/macports/macports-ports.git (fetch)
> origin	https://github.com/macports/macports-ports.git (push)
> 
> Possibly relevant: I do, of course, use two-factor authentication, but I just supplied my password; I was not asked to provide a two-factor auth token. I remember having to follow some instructions to set up GitHub Desktop with some kind of access to allow it to commit, but that was months ago so I couldn't tell you what I did.

With 2FA, you will either have to use a GitHub Access Token for
https://, or use SSH with your public key instead.

https://help.github.com/articles/providing-your-2fa-authentication-code/#through-the-command-line

>> One small addendum: Before "git push origin master", you should run "git
>> pull --rebase" to get any new commits that were pushed by other
>> committers.
> 
> I assume if this was necessary I would have received an error message when I tried to push?

Yes.

Rainer


More information about the macports-dev mailing list