On Local when any Change...
git add -> git commit -> git push origin main

On Server...
git pull origin main

The overall process

People often call this:

Git-based deployment

Deploy via git pull

Or simply: push to GitHub, pull on server

---
on local

# 1. Stage everything you changed
git add .

# 2. Commit with a message
git commit -m "Use MariaDB for TODO storage"

# 3. Push to GitHub
git push origin main

on server

login as owner of the site then
su - cloud # or ssh in as cloud
go version # should also show go1.22.0

cd ~/public_html
git pull
go build -o todo-app

login to root
su

sudo systemctl restart todo-app
sudo systemctl status todo-app

#git #command #common #github
You can totally do that 👍
Think of it like this:

1. Your backup folder = the code you want
2. Your Git repo = the thing connected to GitHub
3. You copy backup → repo, commit, then (maybe) force-push to make GitHub match.

I’ll assume:

* Your WSL project repo is: ~/projects/go/todo-api
* Your backup is somewhere like: ~/backup/todo-api-backup

---

## A. Make your local repo match the backup

1. Go to your repo:


   cd ~/projects/go/todo-api


2. (Optional, but safer) Clean out current files except .git:


   rm -rf *
rm -rf .[^.]* 2>/dev/null # removes dotfiles but keeps .git if it exists


> If rm -rf .[^.]* scares you, skip it and just overwrite files when copying.

3. Copy the backup contents into this repo:


   cp -r ~/backup/todo-api-backup/* .
cp -r ~/backup/todo-api-backup/.* . 2>/dev/null || true


> If your backup also has a .git folder, this will overwrite your current .git.
> That’s fine as long as its origin is still set to https://github.com/kenzastore/todo-api.git.
> We’ll check that next.

4. Check git status and remote:


   git status
git remote -v


You should see:

* lots of changes (or “untracked files”)
* origin https://github.com/kenzastore/todo-api.git

If there is no .git (i.e. git status says “not a git repository”), then:


   git init
git branch -M main
git remote add origin https://github.com/kenzastore/todo-api.git


---

## B. Commit the backup as the new version

git add .
git commit -m "Restore original Go app from backup"


Now your local main branch = backup code.

---

## C. Decide: overwrite GitHub or merge?

### 1️⃣ If you want GitHub to match the backup (overwrite)

This will throw away newer commits on GitHub and replace them with your backup.

git push -f origin main


* -f = force (required because history is different)
* After this, GitHub’s main will look exactly like your local code.

### 2️⃣ If you want to keep GitHub history and merge backup in

Then instead of forcing, you’d first pull and rebase:

git pull --rebase origin main
# resolve any conflicts
git push origin main


But from how you described it (“backup of the original go folder”), you probably want option 1: force-push so everything goes back to that state.

---

## D. Update the server from GitHub

Once GitHub has the backup version:

On the server as user cloud:

cd ~/public_html
git fetch origin
git reset --hard origin/main # make server code exactly match GitHub
go build -o todo-app


Then as root:

systemctl restart todo-app
systemctl status todo-app


Now:

* WSL code = backup
* GitHub = backup
* Server = backup build, running on your domain

---
#git #command #common #github #backup #upload #change #file #wsl #server