So it's possible and quite convenient to use hardcode git commands to checkout Github repositories. It works fine, once you get the SSH keys sorted out and all that.
I tend to use IntelliJ to checkout new github repositories, as it is soo much easier to point and click.
This always happens to me, when I find myself having to do things I don't do often. Because once you have a repo checked out, that's basically the end of all the complicated stuff and you just get to work.
Checking out using Git
I still prefer using Git to checkout a new repository for now4.
The way this works is just do "git clone git@github.com:username/repo.git". You can find this url in the repository on the GitHub website.
However, an ssh key must be available on your GitHub account for the computer/client you're using.
First generate such an ssh key on your computer, using reference [5].
For example: "ssh-keygen -t ed25519 -C "mrbear@mrbear.com"".
Add your ssh key to the ssh-useragent, using "ssh-add ~/.ssh/id_ed25519".
You should see:
Enter passphrase for /home/mmrbear/.ssh/id_ed25519:
Identity added: /home/mrbear/.ssh/id_ed25519 (mrbear@mrbear.com)
Then you can add the generated key to your Github account using the website, using reference [6].
After that, you can finally just clone your repo as mentioned above.
Installation
GitHub has a command line interface nowadays1. It's easy to install2.I'm using Fedora, so all it takes on my end is to "sudo dnf install gh".
There used to be a tool called "hub", apparently, which is basically a git wrapper for GitHub. It was an unofficial tool. You can find the differences discusses in [3].
Using the CLI
Logging in using "gh auth login".
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? SSH
? Upload your SSH public key to your GitHub account? Skip
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: DFGF-JFDB
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Logged in as mrbear
Then the command "gh issue list" shows me open issues.
Works! Quite nice!
References
- [1] GitHub - Take GitHub to the command line
- https://cli.github.com/
- [2] Installing gh on Linux and BSD
- https://github.com/cli/cli/blob/trunk/docs/install_linux.md
- [3] GitHub - GitHub CLI & hub
- https://github.com/cli/cli/blob/trunk/docs/gh-vs-hub.md
- [4] GitHub - Cloning a repository
- https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
- [5] GitHub - Generating a new SSH key and adding it to the ssh-agent
- https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
- [6] GitHub - Adding a new SSH key to your account
- https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
No comments:
Post a Comment