How to Upload Local Scripts to a Specific Folder in a GitHub Repository

Use Case:

You have a set of files (e.g., .py, .ipynb, etc.) on your local machine and want them to appear inside a specific folder(e.g., Clinical_trial_monitoring_system/scripts/) of an existing GitHub repository.


Prerequisites

• You have Git installed (git –version)

• You have a GitHub repository already created

• You have terminal/command line access


Step-by-Step Instructions

1. Clone your GitHub repository

Clone the target repository to your local machine:

git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git
cd YOUR_REPOSITORY_NAME

For example:

git clone https://github.com/smthorat/Machine-Learning-and-Deep-Learning.git
cd Machine-Learning-and-Deep-Learning

2. Create the target subfolder (if it doesn’t exist)

mkdir -p Clinical_trial_monitoring_system/scripts

3. Copy your local scripts into this folder

Replace the path below with your actual local folder path.

cp -R /Volumes/Jagannath/Projects/Clinical\ project/new_data/scripts/* Clinical_trial_monitoring_system/scripts/

Use cp -R to copy recursively, including any subfolders.


4. Check the files (optional but recommended)

ls Clinical_trial_monitoring_system/scripts/

5. Stage the files for commit

git add Clinical_trial_monitoring_system/scripts

6. Commit the changes

git commit -m "Add core scripts and notebooks to Clinical_trial_monitoring_system"

7. Push to GitHub

git push origin main

Final Folder Structure on GitHub (after push)

Your files will now show up in this structure:

Machine-Learning-and-Deep-Learning/
└── Clinical_trial_monitoring_system/
    └── scripts/
        ├── clinical_trial_dashboard.py
        ├── prediction_model.ipynb
        └── new_data.ipynb

Tips

• If the repo has existing content and you get a “rejected” error when pushing, run:

git pull origin main --allow-unrelated-histories --no-rebase
git push origin main

• Always double-check with git status before committing.

• You can save this script as a shell alias or bash script for automation.