Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving a git repository up one hierarchy level

Git beginner question:

I have a small private webproject which is versioned locally with msysgit. There is no exterior repository, as it's only for me, so i can bascially do whatever I want.

I've had this set up in the project directory, ie in "webroot".

Now a second directory had to be created, placed parallel to webroot. Let's call it assets.

So structure is now as follows:

\ project directory ----\webroot ----\assets 

I'd love to include this new directory in the git repository, so that I'd also version changes to files stored there, but of course I can't use "git add ../assets". Neither am I inclined to create a new git project in project_directory, as this would loose all my previous commits.

So how do I go about moving the repository out of "webroot" up into "project_directory", while keeping my commits and then being able to include "assets"?

like image 631
Sorcy Avatar asked Mar 23 '11 16:03

Sorcy


People also ask

How do I copy a repository from one organization to another?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under "Danger Zone", click Transfer. Read the information about transferring a repository, then type the name of the user or organization you'd like to transfer ownership of the repository to.


1 Answers

So, you want your git repo to look like this:

<projectdir>     /.git     /webroot     /assets 

To do this, you must move the existing files in your repo into a new webroot subdirectory.

cd <git repo root> mkdir webroot git mv <all your files> webroot git commit --all -m "moved all existing files to new 'webroot' directory" 

Then, on your local filesystem you want to relocate your clone one directory above where it is now:

cd <projectdir> mv webroot/* . rmdir webroot 

Then you want to add the assets directory (and files) to the git repo:

git add assets git commit -m "added assets to the repo" 
like image 68
Tim Henigan Avatar answered Sep 28 '22 06:09

Tim Henigan