Index: An Incremental Blog
Newer: Recipe: rsync-in
Older: Fixing Filenames
[ Vlado Keselj | 2021-05-21..2021-05-22 ]

Recipe: GitHub Upload

This is a brief recipe about quick project upload to GitHub:
  1. Create a local git repository in your project directory:
     $ git init
  2. Add all files that you want included; maybe check MANIFEST; e.g.:
     $ git add README MANIFEST README.pod LICENSE
  3. Commit the files; e.g.:
     $ git commit -m'Initial Commit'
  4. Create the GitHub repository using web browser by logging in to the GitHub site; you will need a repository name and optionally description; e.g., App-Utils.
  5. Define the GitHub repostory as a remote repository; e.g.:
     $ git remote add github git@github.com:youruserid/Your-Prj.git
    I would use:
     $ git remote add github git@github.com-vkeselj:vkeselj/App-Utils.git
    because I use a separate ssh key for GitHub.
  6. Push the project to your new created repository:
     $ git push -u github master
  7. Check the repository, and that is it.
  8. If you make some changes, you and add all modified tracked files:
     $ git add -u  # add modified tracked files
    and use again git commit and git push as above to push changes.

Using a Separate SSH Key

In the above recipe, I suggested adding GitHub as a remote repository as:
$ git remote add github git@github.com-userid:userid/My-Prj.git
rather than the standard:
$ git remote add github git@github.com:userid/My-Prj.git

This is done so that we can use a dedicated SSH key for GitHub, rather than our default SSH key. In order to make this work, we need to use the command ssh-keygen to generate a separate private-public key pair in the directory .ssh, named for example as id_rsa-github and id_rsa-github.pub.

We then edit the file ~/.ssh/config to contain:

Host github.com-userid
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa-github
and then whenever we access host github.com-userid via SSH or git as in the command above, the appropriate key will be used.

We also need to make sure that this public SSH key is uploaded to GitHub in our account.


created: 2021-05-21, last update: 2021-05-22, me comments

© 2021-2023 Vlado Keselj, last update: 14-Feb-2022