We are migrating SVN to Git. On a project.
Everything is well but I have a problem with preserving the permissions (file mode) of some untracked (ignored) dirs and files. We the following process:
- CleanUp the SVM repo (tidy up, clean uncommited stuff and so forth)
- svn2git on local environment (migrating from networked SVN - so latest rev, no further commits, this does include a proper
authors.txt
mapping and proper tracking of branches, tags, etc.) - Create ignored files & dirs li (.gitignore)st - partially automated from
svn propget
, manual finish (row by row) Add the remote and push to it (We're using github but it should hardly matter)
At this stage the remote is ready, all the history is converted. Now comes the hard part I want to hot-migrate the server deployments without changing the dirs, moving files or creating symlinks. Let's say there are two mirrored environments are on two different servers - one for beta and one for prod. Let us say the dir is
/var/www/depl/
for example/. The thing is that as every Web project, there are dirs and files that we don't need to track. I will be writing my steps wit the commands since I think it could also be a nice guide for others. So the strategy for on the servers is:Go there
cd /var/www/depl/
- BackUp to another dir via
rsync
and preserve the permissions as they are!! - Delete all .svn directories recursively
find -type d -name .svn -exec rm -rf {} \;
- Init an empty git repo
git init
(notice we're not using a 'bare' repo) - Add the GitHub remote and call it "origin", also download all branches
git remote add -f https://github.com/ORG/REPO
- Check status (the local copy should be clean)
- Pull (so fetch + merge but it is actually only a merge)
git pull origin master
This last step is what breaks my permissions. Remember those files that I don't want/need to track? It now seems that those have their permissions modified. They are all properly ignored but when I apply the pull/merge it breaks. OK, for sure the issue is coming from the remote repository and via the merge. And it is not an issue, but rather how the files were commited (with what file modes).
The question is: At the last step, when pulling the updates in, can I instruct git to preserve the current file permissions for all files? As in the current dir and recursively down? So: do not change any local permissions?
Yes, maybe I will have a diff and stuff to commit afterwards, but that is not such a big issue as are the broken permissions.
So? Is there a way? The servers are running Linux of course.
Thanks in advance.
Cheers!