Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Kris Byrum
Kris Byrum
32,636 Points

Moving a Git Repo

I tried to find this online, but could not.

I have a git repo that I have been using a bunch in a folder.

I am now waning to move this git directory into a new folder WITH all my history.

I have been pushing commits to my GitHub account.

Is this possible? How would I go about doing this?

If I loose the history or can't do the move it won't break anything. I just have the majority of my other git repos in this new folder.

Thanks!!!

1 Answer

Just move your repo anywhere you want. All the git 'history' is located inside that that repo inside the .git folder. That's the beauty of a decentralized system, everything you need is in the repo.

Kris Byrum
Kris Byrum
32,636 Points

Thanks Asjer, but I can't figure out HOW to move it.

I've tried git mv .git PATH-To-New-File-Location, but it gives me a fatal error message

../../../../xammp/htdocs/ is outside repository

No problem Kris. If this is your repo: it has the .git folder inside. If you want to move the repo, you should just move and leave .git alone.

I'm not sure what you mean you don't know HOW to move it. Are you working from GUI or CLI? If you working from CLI you should be able to move with the mv command unless you don't have enough permissions.

Oh wait, I think I understand what you want. You want to go from /../../repo_name to /../../otherrepo_name, correct? Best way is to clone: git clone /../../repo_name /../../otherrepo_name