This passage covers the major steps of deploying your local project (files in a well-structured folder) onto a Github repository. Here we take ~/Desktop/XGBoost as an example, in which I have three Python scripts and a Readme.md doc. Make sure you have the command line tool Git installed already.

  1. Open Terminal.app and enter the directory of the folder.

    1
    cd ~/Desktop/XGBoost

  2. Initialize the directory to a Git project.

    1
    git init

Now you'll see a .git file (which is hidden actually, but you can opt to show hidden files using terminal commands) in the folder XGBoost. (3) Add all files into the local Git project.

1
git add .

You can substitute . with the files you want to add, e.g. main.py, if not all items in the directory do you want to deploy. (4) Deploy your local project to Github.

1
git commit -m "Initial commit"

  1. Visit Github. Create a new repository named XGBoost or whatever. Copy the .git url of your repository, e.g. https://github.com/allenfrostline/xgboost.git
  2. Go back to the terminal and type the following.

    1
    git remote add origin https://github.com/allenfrostline/xgboost.git

  3. Run the following script to see if you've seccessfully deployed your files.

    1
    git remote -v

  4. Any time in the future if you want to deploy/update your files, run under the same directory:

    1
    git push origin master


Refference: Adding a file to a repository using the command line