1

I have a real mess on my hands. I have a private GitHub repo that I own and am the sole contributor/maintainer of. So whatever hackery is required to solve my problem will only affect me and no one else.

Here's my situation:

  1. My GH repo is, say, https://github.com/mygithubuser.example.com/myapp.git. I have a local clone of myapp at, say, ~/sandbox/workspace/myapp.
  2. I deleted ~/sandbox/workspace/myapp/.git (effectively disconnecting it from git/GitHub) and renamed it to ~/sandbox/workspace/myapp-old.
  3. I created a new barebones app project locally at ~/sandbox/workspace/myapp.
  4. Inside that new myapp dir, I did: (a) git init, (b) git add ., (c) git commit -m "Starting over again.".
  5. I now want to somehow connect the new local myapp repo to my GitHub repo at https://github.com/mygithubuser.example.com/myapp.git, and completely blow out anything that is in that remote repo with everything that is in the new local myapp repo.

So again, I want to force GH to allow a push from my new myapp repo to override everything that is in my remote GH repo.

We have to pretend that myapp-old, although it exist locally on my machine, cannot be part of any solution. We have to pretend like it no longer exists.

I found this answer but it's not working for me. What can I do? What are the exact Git command-line invocations I can run to accomplish what I'm looking for?


Please note there is a specific reason for why I need to do exactly what I'm asking for here. To explain why would require me to launch into a very long backstory that would be dry, boring, and would make this question a strong candidate for downvoting/closevoting. So please don't ask me "Why are you doing this?"- or "Why don't you just X"! I promise you there is a good reason for it.

Community
  • 1
  • 1
smeeb
  • 27,777
  • 57
  • 250
  • 447
  • "but it's not working for me" -- That's exactly what should work just fine. You already managed to get it working some other way, so I suspect you won't want to spend more time on this, but for future questions, please be more specific, include the exact command-line you *did* use, and the output it gave you. –  Oct 24 '15 at 10:35

1 Answers1

0

After sleeping on this for a night, it just dawned on me (no pun intended) what the best solution is. Posting it here for any future git-newbs in the same dilemma.

  1. Disconnect the new repo (~/sandbox/workspace/myapp) from Git (rm -rf .git)
  2. Get the new repo working the way I want it
  3. Rename the new repo (e.g. mv ~/sandbox/workspace/myapp ~/sandbox/workspace/meh)
  4. Clone the GH repo to myapp (git clone https://github.com/mygithubuser.example.com/myapp.git), which yes, produces yet another ~/sandbox/workspace/myapp, based on the old one
  5. Copy changes over from /meh to myapp
  6. Push
  7. ...
  8. Profit
smeeb
  • 27,777
  • 57
  • 250
  • 447