Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Can I put all contents in a sub folder and still have history [duplicate]

Tags:

git

Possible Duplicate:
Is it possible to move/rename files in git and maintain their history?

I am a previous subversion user, not sure how git could help me in following situation.

I have a git repository where my project was contained having multiple dirs, I've been making several commits over this structure

Now I need to make structure changes, so that I move all folders/files at root to a new folder, and I still want to keep commit history of files.

so for example in my repo I currently have a structure like this

src
res
xml
file.txt
.gitignore

I want all of them to be moved in a folder called common, so that I have following structure at the root of repo

common
.gitignore

Is it possible , if so how ?

Thank you

like image 829
Ahmed Avatar asked Feb 19 '23 09:02

Ahmed


1 Answers

You could use commands like this

mkdir common
git mv src res xml file.txt common

This moves the files and you can still see the history with git log --follow common/file.txt. If you'd rather rewrite history, check out How can I rewrite history so that all files, except the ones I already moved, are in a subdirectory?

like image 123
fidian Avatar answered Feb 20 '23 21:02

fidian