You can upload an existing file to a GitHub repository using the command line.
Tip: You can also add an existing file to a repository from the GitHub website.
This procedure assumes you’ve already:
- Created a repository on GitHub, or are a collaborator on someone else’s repository.
- Cloned the repository locally on your computer
- On your computer, move the file you’d like to upload to GitHub into the local directory that was created when you cloned the repository.
- Open Terminal.
- Change the current working directory to your local repository.
- Stage the file for the first commit to your repository.
git add . # Adds the files in the local repository and stages them for commit.
- Commit the files that you’ve staged in your local repository.
git commit -m "First commit" # Commits the tracked changes and prepares them to be pushed.
- Push the changes in your local repository to GitHub.
git push origin master # Pushes the changes in your local repository.
Org: Github Help