I've got the following source structure:
/dir1
file1
file2
file3
dir1
is unneeded as the repository itself can be like a folder, so I want my git repository to look like this:
file1
file2
file3
What should I do to achieve this?
Yes, it is safe to rename the folder containing a Git repository. All paths inside the Git repository are relative.
bashrc or if you use zsh in ~/. zshrc and you're all set. Whenever inside a git repo and want to cd to its root, typing gitroot will take you to its root dir.
In your repository, browse to the file you want to move. In the upper right corner of the file view, click to open the file editor. To move the file into a subfolder, type the name of the folder you want, followed by / . Your new folder name becomes a new item in the navigation breadcrumbs.
DISCLAIMER: this will rewrite history and be a PITA for anyone who has already cloned your repository. You shouldn't do it on published history.
That said, you should be able to rewrite all your trees by using the filter-branch
command of Git. Be sure to understand all implications before using it (please, read the manpage; have backups).
git filter-branch \
--subdirectory-filter dir1 \
--tag-name-filter cat \
-- --all
NB. This command will also perist your grafts and replace refs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With