How to Start a Local Git Repo and Upload it to GitHub

You start to write code locally in a directory and you want to keep track on file changes in a Git database and then upload (push) it to GitHub.

You have some files already in a directory and you start a Git repo locally by executing git init.

Now stage it and commit it.

git add .

git commit -m 'initial commit'

Once you create a repo on GitHub, you have a link to the GitHub repo in the page. Using that SSH repo link, you can push it to GitHub.

Now configure the remote repo in local Git database.

git remote add origin git@github.com:hiriumi/oci-resources.git

And then, push it to the upstream repo.

git push --set-upstream origin master

You won’t need --setup-upstream origin master from the subsequent pushes.

Author: admin

A software engineer in greater Seattle area

Leave a Reply

Your email address will not be published. Required fields are marked *