So there I was, staring at my terminal like it had personally betrayed me.
$ git push origin main remote: Repository not found. fatal: repository 'https://github.com/old-org/repo.git/' not foundRepository not found.
Buddy, I JUST pushed to this repo yesterday. Where did it go?
Then I remembered—oh right, I renamed the GitHub organization last week. Changed the URL from old-startup-name to actual-legit-company-name because we're professionals now. Except I forgot to tell Git about the memo.
The Discovery
Here's the thing nobody tells you: when you rename your GitHub org or username, GitHub is nice enough to redirect traffic from the old URL to the new one. For a while. But Git? Git doesn't care about your redirects. Git is literal. Git wants the actual URL.
And when that redirect expires—or if you're using SSH keys—you're cooked.
Your local repository's remote is still pointing to:https://github.com/old-org-name/repo.git
But GitHub now expects:https://github.com/new-org-name/repo.git
Result: Git doesn't know where to push.
The Solution
Step 1: Check Your Current Remote
First, let's see what Git thinks the remote URL is:
$ git remote -vYou'll see something like:
origin https://github.com/old-org/repo.git (fetch) origin https://github.com/old-org/repo.git (push)Yep. There's your problem.
Step 2: Update the Remote URL
This is the magic command:
$ git remote set-url origin https://github.com/new-org/repo.gitIf you're using SSH (you fancy developer, you):
$ git remote set-url origin git@github.com:new-org/repo.gitThat's it. Literally. No ceremony, no migration scripts, no prayer circles. Just tell Git the new address.
Step 3: Verify the Change
Always verify. Trust, but verify.
$ git remote -vYou should now see:
origin https://github.com/new-org/repo.git (fetch) origin https://github.com/new-org/repo.git (push)Beautiful. Kiss the chef.
Step 4: Test It
$ git push origin mainIf that works without throwing a tantrum, you're golden.
Visual Guide
┌─────────────────────────┐
│ Local Repository │
│ │
│ Your Branches: │
│ ├─ main │
│ ├─ feature-1 │
│ └─ hotfix │
│ │
│ Remote "origin": │
│ └─> github.com/ │
│ old-org/repo ❌ │ <-- PROBLEM
│ │
└─────────────────────────┘
↓
git remote set-url
↓
┌─────────────────────────┐
│ Local Repository │
│ │
│ Your Branches: │
│ ├─ main │
│ ├─ feature-1 │
│ └─ hotfix │
│ │
│ Remote "origin": │
│ └─> github.com/ │
│ new-org/repo ✅ │ <-- FIXED
│ │
└─────────────────────────┘What About Your Team?
Quick PSA: if you're on a team, everyone needs to update their remotes. This isn't a one-person fix.
The good news? The command is the same for everyone:
$ git remote set-url origin https://github.com/new-org/repo.gitSend that in Slack. Watch the 👍 reactions roll in. Bask in the glory of solving a problem before it becomes everyone's problem.
✓ Your local branches are fine—they don't need updating
✓ Your commit history stays exactly the same
✓ If you have multiple remotes (origin, upstream, etc.), update each one
✓ Forked repos might also need their upstream remotes updated
✓ CI/CD pipelines using the old URL? Those need manual fixes too
Remotes are just bookmarks. That's it.
When you run git remote set-url, you're not moving your code, you're not rewriting history, you're just updating a pointer. Git doesn't care what the URL is—it cares that the URL works.
This is one of those "looks scary, actually simple" moments. And honestly? That's most of Git.
P.S. – If you're reading this because you just panic-Googled "git push 404 after rename," welcome. Take a breath. Run the command. You'll be fine.