MyWeb Tutorials: Git (Version Control) Recommended Workflow (Read First) If you are planning to use GIT, then you need to consider our GitLab server is the source of truth for your website code. You should write and edit your code locally on your own computer using any editor or IDE (such as VS Code). Your local project must be connected to gitlab.cs.uwindsor.ca, where you commit and push your changes. Once your code is pushed to GitLab, you then log in to MyWeb (DirectAdmin) and use Fetch followed by Deploy to publish the latest version of your code to the web server. Do not edit files directly in MyWeb using File Manager or FTP after Git is enabled, as those changes will be overwritten on the next deploy.   Summary of Workflow: Edit locally on your computer Commit & push to GitLab Fetch & Deploy to MyWeb First-Time Setup (Do Once) Create an SSH key on the student’s local computer Add the local SSH key to GitLab (gitlab.cs.uwindsor.ca) Configure your IDE (e.g., VS Code) to use GitLab Create a new project on GitLab and copy the SSH remote URL Initialize the local project and connect it to the GitLab repository If code already exists on MyWeb, import it into the local project Commit and push the initial codebase to GitLab Create a separate SSH key in MyWeb (DirectAdmin) for deployment Add the MyWeb public SSH key to GitLab Initialize and connect the Git repository in MyWeb Perform the first Fetch and Deploy from GitLab to MyWeb   Daily / Ongoing Workflow Edit code locally on the student’s computer Commit and push changes to GitLab Log in to MyWeb (DirectAdmin) Fetch updates from GitLab Deploy the latest code to the website 1. Create an SSH key on the student’s local computer SSH keys are used to connect your computer to GitLab securely If you already have an SSH key, you may reuse it For simplicity and clarity, it is recommended to create a new SSH key specifically for GitLab Windows (Windows Terminal / PowerShell / Git Bash) Open Windows Terminal , PowerShell , or Git Bash Generate a new SSH key: ssh-keygen -t ed25519 -C "yourusername@gitlab.cs.uwindsor.ca" When prompted: File location : press Enter to accept default (or use gitlab_cs if you want a dedicated key) Passphrase : optional (press Enter to skip) Start the SSH agent: eval "$(ssh-agent -s)" Add the key to the agent: ssh-add ~/.ssh/id_ed25519 (or the filename you chose)   macOS / Linux Open Terminal Generate a new SSH key: ssh-keygen -t ed25519 -C "yourusername@gitlab.cs.uwindsor.ca" When prompted: File location : press Enter to accept default Passphrase : optional (press Enter to skip) Start the SSH agent: eval "$(ssh-agent -s)" Add the key to the agent: ssh-add ~/.ssh/id_ed25519   Verify the Key Was Created (All Systems) List SSH keys: ls ~/.ssh You should see: id_ed25519 id_ed25519.pub Notes for Students: .pub file = public key (safe to share) non-.pub file = private key (never share) Public key will be added to GitLab in the next step You do not need to repeat this step unless you change computers   2. Add the SSH Key to GitLab (gitlab.cs.uwindsor.ca) Open GitLab in your browser: https://gitlab.cs.uwindsor.ca   Log in with your CS credentials Open User Preferences Go to SSH Keys Copy Your Public Key (from your computer) Display the public key: cat ~/.ssh/id_ed25519.pub (If you used a different filename, replace id_ed25519 accordingly.) Select and copy the entire output (starts with ssh-ed25519) Add the Key in GitLab Paste the key into the Key field (Optional) Set a descriptive Title (e.g., Laptop – CS GitLab) Click Add key Quick Verification (Optional but Recommended) Test the SSH connection: ssh -T git@gitlab.cs.uwindsor.ca You should see a success message indicating authentication worked Notes for Students You can add multiple SSH keys to the same GitLab account (one per device) This key is for your local computer only Do not upload private keys (id_ed25519)—only the .pub file   3. Configure Your IDE (VS Code) to Use GitLab Install Visual Studio Code if it is not already installed Ensure Git is installed on your system and available in your terminal Open VS Code Verify Git Is Detected by VS Code Open the integrated terminal in VS Code: View → Terminal Check Git availability: git --version If Git is detected, VS Code will automatically enable source control features   Configure VS Code to Use Your SSH Key Ensure the SSH agent is running (from earlier step) Confirm your SSH key is loaded: ssh-add -l You should see your id_ed25519 (or chosen key name) VS Code uses the system SSH configuration automatically— no extra setup is required if SSH works in the terminal.   (Optional but Recommended) Configure Git Identity Set your name and email (used in commits): git config --global user.name "Your Full Name" git config --global user.email "yourusername@uwindsor.ca"   (Optional) Test GitLab Access from VS Code From the VS Code terminal, test SSH: ssh -T git@gitlab.cs.uwindsor.ca A success message confirms VS Code can authenticate with GitLab   Notes for Students VS Code does not store your SSH key; it uses the system SSH agent If Git works in the terminal, it will work in VS Code You only need to do this setup once per computer   4. Create a Project on GitLab and Get the SSH Remote URL Open GitLab in your browser: https://gitlab.cs.uwindsor.ca   Log in with your CS credentials Click New Project Choose Create blank project Project Setup Enter a Project name (e.g., myweb-project) Leave Visibility as default (Private) Click Create project Get the SSH Remote URL After the project is created, open the project page Click Code (or Clone ) Select SSH Copy the SSH URL, which looks like: git@gitlab.cs.uwindsor.ca:yourusername/myweb-project.git   Notes for Students Always use the SSH URL , not HTTPS This URL will be used to connect: Your local project Your MyWeb deployment You only create the GitLab project once   5. Initialize the Local Project and Push Code to GitLab This step connects your local code to the GitLab repository you just created.   If You Are Starting with New Code (No Existing MyWeb Files) Open a terminal inside your project folder Initialize Git: git init Add the GitLab remote (use the SSH URL you copied): git remote add origin git@gitlab.cs.uwindsor.ca:yourusername/myweb-project.git Add all files: git add . Commit the initial version: git commit -m "Initial commit" Push to GitLab: git branch -M main git push -u origin main If Code Already Exists on MyWeb (Common Case) First, make sure your local project folder contains the files from MyWeb (public_html) Download them from MyWeb (zip or File Manager) Or copy them manually Then, inside that folder: git init git remote add origin git@gitlab.cs.uwindsor.ca:yourusername/myweb-project.git git add . git commit -m "Initial import from MyWeb" git branch -M main git push -u origin main ✔ GitLab now contains the full website code ✔ GitLab becomes the source of truth   Notes for Students This initialization happens once After this step: Do not treat MyWeb as the main copy All future changes start locally   6. Create a Deployment SSH Key in MyWeb (DirectAdmin) This key is used only by MyWeb to fetch and deploy code from GitLab. It is separate from the SSH key on your local computer. Log in to MyWeb (DirectAdmin) Go to Advanced features →  SSH Keys Click Create Key Fill in the fields Key ID : gitlab (or any short name) Authorize : ✔ checked Comment : yourusername@gitlab.cs.uwindsor.ca Key Size : 2048 Password : leave empty Click Create Copy the Public Key After creation, copy the public key (the .pub content) You will add this key to GitLab in the next step To copy the public key, right click on *.pub file and open/edit it and copy the full content (to be used in step 7 below) Notes for Students This key stays on the server Do not download or reuse it on your computer One MyWeb key can be reused for multiple repositories   7. Add the MyWeb SSH Key to GitLab This step authorizes MyWeb to access your GitLab repository for Fetch and Deploy . Open GitLab in your browser: https://gitlab.cs.uwindsor.ca   Log in with your CS credentials Go to User Preferences Select SSH Keys Add the MyWeb Public Key Paste the public SSH key you copied from MyWeb Set a clear Title (e.g., MyWeb Deployment Key) Click Add key Notes for Students This key is server-side only (deployment) It is different from your local computer’s SSH key GitLab allows multiple SSH keys per account   8. Initialize and Connect the Repository in MyWeb (DirectAdmin) This step links MyWeb to your GitLab repository so it can deploy your code. Log in to MyWeb (DirectAdmin) Go to Advanced Features -> Git Click Create Repository Fill in the Repository Details Domain : select your MyWeb domain (auto-filled) Name : any label (e.g., myweb-site) Remote : paste the SSH URL of your GitLab repository git@gitlab.cs.uwindsor.ca:yourusername/myweb-project.git Keyfile : select or enter the path to the private key created in MyWeb .ssh/gitlab  (the exact file name you have in .ssh folder) Click  Create Repository What This Does Creates a local Git repository on MyWeb Links it to GitLab using SSH Prepares MyWeb for deployment (no files are changed yet)   Notes for Students Always use the SSH remote , not HTTPS Do not include full /home/... paths in the Keyfile field This setup is done once per project   9. Fetch and Deploy the Code to MyWeb This step publishes your GitLab code to your MyWeb website .   Fetch From GitLab In MyWeb (DirectAdmin) , go to Git Locate your repository Click the three dots ( ⋯ ) next to it Click Fetch What Fetch does: Connects to GitLab Retrieves the latest commits and branch information Does not change your website files Deploy to MyWeb Click the three dots ( ⋯ ) again Click Deploy What Deploy does: Checks out the latest commit (usually from main) Copies files into: public_html/ Makes the code live on your website   Verify Deployment Open File Manager Confirm files appear in public_html Visit your website in a browser: https://yourproject.myweb.cs.uwindsor.ca/   Important Notes for Students Always Fetch before Deploy Do not edit files in File Manager or via FTP after Git is enabled Manual changes will be overwritten on the next deploy   ✅ Setup Complete You have now: Connected your local computer to GitLab Connected MyWeb to GitLab Deployed your site using Git Daily Workflow Reminder Edit code locally Commit and push to GitLab Fetch and Deploy from MyWeb