project-folder/
.git
wp-admin/
wp-content/
wp-includes/
.htaccess
...
project-folder/
.git
public
wp-admin/
wp-content/
wp-includes/
.htaccess
...
- Keep away from the Internet my
.git
folder - Wordpress files separated in a sub-folder
- Keep Git history changes
- Hide from the Internet deployment scripts or project sensitive informations
-
Be sure you don't have files uncommitted, if not commit them before next step.
git status
-
In project-directory create
public
subfoldermkdir public
-
Move files with
git mv
exceptpublic
subfolder to avoid errorsfor file in $(ls | grep -v 'public'); do git mv $file public; done;
-
Move specific files like .htaccess etc...
git mv .htaccess public/
-
Commit changes
git commit -m 'Moved files to public/'
-
That's all !
git log -M summary
git log --follow
http://git-scm.com/docs/git-log
On logging file(s) you have to check [x] Follow renamed files
If you're coming to this gist from Google looking for "the right way" to rename files while retaining git history, the title is a bit misleading:
Nothing in the steps especially helps keep the history intact, it's just relying on
git log --follow
like any other time you move files. Thegit mv
command used in step 3 doesn't do anything special:I'd guess most people looking at this have already had problems with
git log --follow
not working for them, so just a heads up this isn't going to solve that problem for you. Unfortunately there's no "correct" way to do this with git. Really the only way to get what you probably want is if you're willing to rewrite your entire history via a rebase, for example using something like this: https://gist.github.com/emiller/6769886 (risky move, be careful!)Sorry to be critical, just thought it was worth the clarification since this was the top result on Google for me for this question.