772
you are viewing a single comment's thread
view the rest of the comments
[-] 30p87@feddit.org 1 points 4 months ago

Huh? I'm talking about existing code being in a dir, then initting a git repo there, creating a pendant on your hoster of choice and then pushing it there. Wouldn't cloning the repo from step 3 to the code from step 1 overwrite the contents there?

[-] stembolts@programming.dev 8 points 4 months ago* (last edited 4 months ago)

There are multiple solutions to this without using --force.

Move the files, clone, unmove the files, commit, push being the most straightforward that I can summon at this time.. but I've solved this dozens of times and have never use --force.

[-] Hoimo@ani.social 3 points 4 months ago

If your remote is completely empty and has no commits, you can just push normally. If it has an auto-generated "initial commit" (pretty sure Github does something like that), you could force push, or merge your local branch into the remote branch and push normally. I think cloning the repo and copying the contents of your local repo into it is the worst option: you'll lose all local commits.

[-] firelizzard@programming.dev 1 points 4 months ago

You can also just tell GitHub to not do that.

load more comments (2 replies)
load more comments (2 replies)
load more comments (4 replies)
this post was submitted on 21 Mar 2025
772 points (98.9% liked)

Programmer Humor

25426 readers
1129 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS