3

I created an original GitHub repository and committed all my code. I would like to move this directory now into a new directory (not in the repo root directory). I am a bit confused how to tackle this (been through Git Help and threads here).

I'm a bit of a GitHub / Terminal newb :-)

This is what I am trying to do:

Projects -> github_project

Projects -> Directory -> github_project

thanks!

gleddy
  • 425
  • 1
  • 5
  • 13
  • Do you want 'Directory' to show up on GitHub? Or do you just want to reorganise the files on your own hard drive (i.e. you want the GitHub repository to look the same after the move as it does now, with all of the project files in the root directory)? – chrismear May 12 '11 at 18:26

1 Answers1

3
  1. Create a new directory in your repo's root.
  2. Move all other files into that directory (using git mv).
  3. Push to GitHub.

Update to address edited question

If you just want to put it in a new directory, then create the new directory and move the repository there.

mipadi
  • 398,885
  • 90
  • 523
  • 479
  • sorry, I should have been more clear (looking at other threads). It's not a sub-directory of the root folder - but actually a directory *outside* of the repo's root. – gleddy May 11 '11 at 20:31
  • Moving outside of the repo root will remove the content from your repo entirely, is that what you're after? – Tekkub May 11 '11 at 21:46
  • exactly, I need to change the location of that root folder. I used to do this by actually deleting the GitHub repo and just starting a new 'git init' within the new folder. I am assuming this would kill all your history as well, so was looking for a better way. – gleddy May 12 '11 at 04:46
  • 1
    Yes, that would destroy history. Why don't you try this... make a fresh clone to work in (just in case). Move all the files out of the root (except the .git folder), then move everything back in in the structure you want. Commit that. That commit should contain just a bunch of renames and maybe a few new files if you introduced ones that weren't versioned previously. – Tekkub May 12 '11 at 21:54
  • thanks for you help guys, I ended up just killing the project and starting it up again from where I wanted it. I had only just started the GitHub repo, so no harm done. I am going to storm ahead, get a book on Git and try to get a bit more Git knowledge under my belt before attempting this again. – gleddy May 16 '11 at 00:13
  • Why is this marked as the correct answer? It doesn't do what the OP asked. @gleddy even clarified that this wasn't what they wanted in the first comment. The question remains: How can you move a git project root directory locally without effecting the content, history, etc? – Wes Modes Feb 16 '15 at 22:27
  • @WesModes: The question has since been edited. At the time this answer was posted, it answered the question. – mipadi Feb 16 '15 at 22:29
  • Alright. Awkward. In any case, it sounds like [this](http://stackoverflow.com/questions/651038/how-do-you-clone-a-git-repository-into-a-specific-folder) is the answer to the question as currently stated. – Wes Modes Feb 16 '15 at 22:33