2

I have a git repository with the name 'XYZ' online, and an android project of the same name linked to it. I've been working on the two for quite some time. I messed up somewhere and deleted the entire online XYZ. I went to android studio, and I found that the commit history was still intact... something I don't want. I've tried everything to disconnect it from the old 'XYZ' git and to have it connect to the new one, with no luck. I'd rather not create a new android studio project with a different name, as I'll have to change a lot of internal stuff.

Anyone passed through something similar?

Tim
  • 41,901
  • 18
  • 127
  • 145
Emad Y
  • 415
  • 4
  • 14
  • 1
    You want to hook up your local project to a different remote repository, and get rid of the git history, effectively only preserving the current state. If you'd push this to the new remote repository you would only have 1 commit that represents the current state of the project - have I got that all right? – Tim Oct 12 '15 at 13:58
  • That would work perfectly. I've done the first part, but can't figure out how to remove the git history? What command would I use for that? (keyword is enough, I'll try to figure out the rest). – Emad Y Oct 12 '15 at 14:01
  • 1
    Remove the `.git` folder to remove the git history. See jdebon answer for all required steps – Tim Oct 12 '15 at 14:15
  • Thanks a lot Tim! Also, your edited title sounds a lot better than my original one. Great work on that. How you guys manage astounds me. – Emad Y Oct 12 '15 at 14:30
  • All you need to do is ask yourself what it is you want to do, and translate that into a readable sentence such that if someone else in the future has the same question he can easily find this page by typing his question in Google. I know that sounds easier than it is. – Tim Oct 12 '15 at 14:33

1 Answers1

7

If I understand well your problem, you want to act like your code stream was brand new (i.e. no Git history), and then plug it back on your new repository? If that's the case:

  1. Delete the .git folder. This will remove the Git nature of your code folder. Source: How to fully delete a git repository created with init?
  2. Run git init again on your code folder.
  3. Run git add -A to add all files to your staging area.
  4. Run git commit -m "Initial commit" to commit your code.
  5. Push to your new online repository, using whatever mean you wish. E.g. git remote add origin <online repo URL> and git push origin master
Community
  • 1
  • 1
Sir4ur0n
  • 1,753
  • 1
  • 13
  • 24
  • 1
    Not exactly what I needed, but good enough information that I could figure out what to do :). Thank you! – Emad Y Oct 12 '15 at 14:29