Git Init Pull

Git Init Pull

Creating a new git repo is a little more involved than one that is already setup but here are the simple steps to get one rolling. I prefer to use SSH over HTTPS due to security and ease of use from the command line.

Setup

We need to first do a few things to make a commit as easy as possible.

  1. Create a ssh key if you haven’t already. This will be placed in ~/.ssh unless you tell it otherwise with the -f flag.

    
    $ ssh-keygen -t rsa -b 4096
    or for a more secure and smaller key file
    $ ssh-keygen -t ed25519
    
  2. Copy your .pub key to your clipboard.

    
    $ cat ~/.ssh/id_rsa.pub
    
    or 
    
    $ cat ~/.ssh/id_ed25519.pub
    
  3. Go to your github page and head to your username icon in the top-right corner and hit settings -> SSH and GPG keys

  4. Paste the .pub key into the New SSH Key and add a title name for the key.

git ssh key add

  1. Next create a new repo by clicking the plus sign -> New Repository in the top left corner.

  2. Choose the name you want here and make it either public or private.

    • Do not add a readme file or .gitignore nor a license at this time. It only makes it harder on the next steps.
  3. Click Create Repository

    • Here it will show you the command to run to get the repo initialized and setup but I will show them here as well.

Initialize and commit

  1. cd <directory/of/new/project>

  2. git init

  3. git add .

  4. git commit -m “initial commit”

    • You might be prompted to verify who you are here. If you are run this below and run #4 again.
    $ git config --global user.email "<email used to setup git account>"
    $ git config --global user.name "<username used on git account"
    
  5. git push

Conclusion

You have now setup a new git repo.