Create a git repository and push to GitHub

Last modified on 2020-04-27

Steps to create a local git repository, then push (upload) to GitHub for hosting.

Let’s go!

1. Install git. On Debian/Ubuntu: sudo apt install git.

2. Create a user configuration by running git config. Variables are stored in ~/.gitconfig file. Example …

$ git config --global "Foo Bar"
$ git config --global
$ git config --list Bar

3. Turn a project currently not under version control into a git repository by running git init inside the project directory.

4. Add files to be tracked and commit …

$ git add
$ git commit -m 'first commit'

5. Sign-up for a free GitHub account.

6. Setup the account to use SSH keys for data transfer. Login and navigate to Settings->SSH and GPG keys. Click New SSH key and copy/paste in your *.pub key. Test the connection by running ssh -T

7. Create a public repository on GitHub. Select +->New repository, fill in the details, and click Create repository.

8. Import. Quick setup is set to SSH and opt for ... or push an existing repository from the command line. Example …

$ git remote add origin
$ git remote -v
origin (fetch)
origin (push)
$ git push -u origin master

Happy hacking!