Create and upload a new project on GitHub command line, Raspbian

In order to work with command line interface I have to create SSH key and upload this key to the GitHub.

Generate Key:
ssh-keygen -t rsa -b 4096 -C "name.surname@gmail.com"
Ensure SSH agent is up and running:
eval `ssh-agent -s`
Add SSH key to ssh-agent:
ssh-add ~/.ssh/id_rsa
Install command line clipboard manager so the content which should be copied to the clipboard can not be copied incorectly:
sudo apt-get install xclip
Copy the content to clipboard:
xclip -sel clip < ~/.ssh/id_rsa.pub
Go to https://github.com/settings/keys and press [New SSH key], write the name and paste the content:
Now lets get down to the business.

Make sure the git is installed on Raspbian operating system:
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install git -y
Let's create new repository in live environment with project name "rpi-stretch":
curl -u 'catonrug' https://api.github.com/user/repos -d '{"name":"rpi-stretch","description":"auto configuration"}'
Let's create local the directory which will go on the internet:
mkdir ~/rpi-stretch
Let's go inside this project directory:
cd ~/rpi-stretch
Tell the computer that is supposed to be a git repository:
git init
Tell the computer where this repository equals online:
git remote add origin git@github.com:catonrug/rpi-stretch.git
Add all files in project:
git add .
Create a commit. Calculate if there is any difference:
git commit -m "first"
after this command I can get:
*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <(null)>) not allowed
As it can see I need to enter github credentials here:
git config --global user.email "name.surname@gmail.com"
git config --global user.name "catonrug"
Make changes online:
git push origin master
All done. If I miss the first step off SSH key upload then in this situation I will receive:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
To debug this situation I can use:
ssh -vT git@github.com
After all, at first, I have to create SSH key and upload to GitHub.
Can in it done with GitHub API? You tell me ;)

No comments: