Contributing Guide: git@github.com:… -> https://github.com/…?

Today Contributing to rclone has this step:

    git remote add origin git@github.com:YOURUSER/rclone.git

It made me stumble, because I was a Git beginner using the default installation of Git for Windows.

Would it fit everybody if it was changed to:

    git remote add origin https://github.com/YOURUSER/rclone.git

or should both the SSH and the HTTPS links be in the guide with a short explanation?

Here is how I stumbled:

    PS> git push -u origin fix-5270-unable-to-initialise-rps
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
 
    Please make sure you have the correct access rights
    and the repository exists.

First some googling to figure out that git push was telling me that it couldn’t find the SSH certificate files for my repository. Then some additional googling to figure why git tried to make an SSH certificate-based connection instead of using the Git Credential Manager - especially because I had no problem seeing my repository in Visual Studio Code. I almost made a set of certificate keys when I finally realised the root cause and found the right solution (for me):

    git remote remove origin
    git remote add origin https://github.com/MYUSER/rclone.git

Apart from this little frustrating challenge I really enjoyed the compact and well-written guide :slight_smile:

That is an interesting point.

I thought you could only read from https repositories but maybe you can push now-a-days too? Does that work with the CLI do you know? Not at computer right now, but I can try tomorrow.

It is really useful to have a new user perspective on this.

You could send a Pull request to update CONTRIBUTING.md

Yes, you can push using HTTPS on all platforms (to my best knowledge). Your are however being asked for credentials on every push unless you use one of the many credential managers.

Git for Windows comes with a credential manager that seamlessly integrates with Git Gui, Git Bash, PowerShell, CMD, Visual Studio Code etc.. All you need is to sign in once and approve access; very similar to establishing a GoogleDrive remote in rclone. It takes much more time and skills to setup SSH on Windows, so the choice is easy for me.

I will send a pull request one of the coming days. Right now I am leaning towards changing the add origin to HTTPS and then adding something like this at the end of the pull request chapter:

If you wish to use SSH when connecting to GitHub, then change your URL like this:

    git remote set-url origin git@github:YOURUSER/rclone.git

On unix platforms ssh keys are relatively easy (but not trivial!) to set up.

I don't know how the push credentials works on the command line with https.

Or we could show both with a # comment so

# Use this if you have an ssh key setup with GitHub
git remote add origin git@github.com:YOURUSER/rclone.git
# Use this otherwise
git remote add origin https://github.com/YOURUSER/rclone.git

Or something like that?

I have created a pull request with this and some additional proposed improvements.

Feel free to accept/comment/modify/reject as you see best fit :grinning:

FWIW, my .gitconfig

[user]
        name = Stephen Harris
        email = sweharris@users.noreply.github.com
[push]
        default = matching
[credential]
        helper = store

And in .git-credentials I have a line

https://sweharris:MAGICNUMBER@github.com

The MAGICNUMBER is generated from the github website.

That lets me push code as the sweharris user via https.

Thanks @sweh, I have already solved my issue. I just needed to use the right URL.

The pull request is a proposed update to prevent others from stumbling like me (without making you or somebody else stumble instead).

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.