Create a Project from Scratch on Github and use Public Keys to Push and Pull Code

Create a Project from Scratch on Github and use Public Keys to Push and Pull Code

Last updated:

There might be more clever ways to do this but this is my current setup.

(This assumes you're using a Public/Private Key pair to interface with github)

This is what I usually do to start working on a project from scratch on my machine while keeping the code on github, using Public keys so I don't need to type in my username and password every time.

  • Create the Repo on github

For the sake of example, say your username is johndoe and your new repo is called my-repo

  • Create an empty directory on your machine and cd to it

(Any name will do.)

    $ mkdir my-directory
    $ cd my-directory
  • Init a git project on the directory

    $ git init
    
  • Add a git remote pointing to your project on github

    $ git remote add github git@github.com:johndoe/my-repo.git
    
  • Done.

Now you can push and pull code to and from github (i.e. git push github master) without the need of providing you username and password every time.