E
E
Elle Solomina2019-08-07 10:54:30
git
Elle Solomina, 2019-08-07 10:54:30

How to add empty folders when importing from SVN to Git script on Windows?

The essence of the problem is that I need to migrate several repositories from SVN to Git on Windows. Some of the repositories have empty folders and they are critical for projects and these folders cannot be deleted without breaking the project.
The git svn clone command has --preserve-empty-dirs option, I use it with add. parameter --placeholder-filename=.gitkeep , but it doesn't work, no way.
It looks something like this:

D system/drivers/twi/.gitkeep
Use of uninitialized value $rec in scalar chomp at C:/Program Files/Git/mingw64/
share/perl5/Git.pm line 557, <$fh> chunk 1.
D system/drivers /twi/
M system.svc
W: -empty_dir: system/drivers/twi

As a result, the folder is not added to the commit history, which is already a problem, because it is impossible to rollback, and after a complete extraction it is also not added in any way.
I tried to get a crutch on the mechanism, that is, to write a command that at least added folders after the fact, and I ended up with two pieces of biodegradable code that don’t even come close to doing what is needed:
This piece creates zero-sized files that Git refuses to process:
for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do (fsutil file createnew %%d/.gitkeep 0 && echo.>%d/.gitkeep)

This one already makes the file 2 bytes in size:
for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do (echo.>%d/.gitkeep)

But in both pieces of code there is a problem with the fact that files are created in all folders, not just empty ones. Also, I don't have the brains to exclude the .git folder and this code crap there too. In general, I just ask more experienced people to help solve the problem because the bottom has been reached, ideally show me where I'm wrong when using git svn clone, or help me add a crutch to somehow commit.
PS I don't want to make a solution under Linux or WSL yet, so it's better to do it natively from under Windows. But if there is a ready-made crutch for Linux, then I would be happy with him.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Elle Solomina, 2019-08-26
@ElleSolomina

No way (I'm too lazy to pervert with this under Windows with flawed and inconvenient syntax). Made a crutch for Ubuntu:

echo The crutches for git svn clone --preserve-empty-dirs command, because it is not working properly.

find . -type d -empty -not -path "./.git/*" -exec echo blablabla>.gitkeep \;

git add --all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question