Move project to subdirectory

I have a git repository in a directory called project :

 [~/project]$ ls abc 

I want to move everything to a subdirectory of the project directory so that it looks like this:

 [~/project]$ ls subdir [~/project]$ cd subdir [~/project/subdir]$ ls abc 

git mv usually works, but I want it to look as if historical commits were always made into this subdirectory from the very beginning. Is there any way to do this?

+4
source share
1 answer

It looks like filter-branch does what I want:

 git filter-branch --tree-filter \ 'mkdir subdir; \ find -maxdepth 1 \ -not -name . \ -not -name .git \ -not -name subdir \ -print0 \ | xargs -0 -I{} mv {} subdir' \ -d /tmp/whatever -- --all 

The -d /tmp/whatever is only intended to execute commands on the tmpfs file system, so there is no IO group with a record.

(In rare cases, /tmp will not mount as tmpfs. You can check with mount | grep tmp .)

+5
source

Source: https://habr.com/ru/post/1439188/


All Articles