I have a directory structure in svn like this:
Project A
branches
tags
trunk
Project B
branches
tags
trunk
...
I want to checkout only trunk directories for all these projects. There are about 400 of these kind of projects so checking out trunk manually won't be an option.
My first guess would be to use svn list, but my shell scripting skills are not up to par and I'm sure how to create the appropriate directories and append 'trunk' and do a checkout.
Anyone willing to point me in the right direction?
TL:DR;
svn list produces something like 'project_a'.
I want to checkout 'project_a/trunk' into 'project_a'.
You can store the list of projects to a file (projects_list), then run this script:
for p in $(cat projects_list); do
mkdir $p
svn co "$url/$p/trunk" $p
done
Here is a way to do it by using the depth flag:
echo Getting Projects the folder structure
svn co http://www.therepo.com/projectsParentFolder --depth immediates
echo Getting the structure for each Project
for /f %%f in ('dir /b .\projectsParentFolder') do svn co http://www.therepo.com/projectsParentFolder/%%f .\projectsParentFolder\%%f --depth immediates
echo Getting the trunk for each Project
for /f %%f in ('dir /b .\projectsParentFolder') do svn co http://www.therepo.com/projectsParentFolder/%%f/trunk .\projectsParentFolder\%%f\trunk --depth infinity
Related
I'm creating a project that covers frontend, backend, and mobile. I've set up git in the project root so all phases could be committed. However, I bootstrapped the frontend folder with create-react-app, which creates a project structure of its own (including git).
As it happens, when there's a git inside a git, it is interpreted as a subproject. I just wanted to commit them all to the same repository. I, therefore, proceeded to eliminate all git references from the frontend folder to have it only in the root.
I tried every trick I could think of and it still hasn't worked, the files are still tracked separately. Here's a list of commands I tried both in Powershell and Git Bash:
rm -rf .git
rm -rf .git*
find . | grep "\.git/" | xargs rm -rf
del /F /S /Q /A .git
rmdir .git
rm -rf .gitkeep
rd .git /S/Q
FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.git*') DO RMDIR /S /Q "%G"
Any hints of how getting it the hell out of my folder?
Thanks!
Removing the .git is a good first step, but what you are missing is the gitlink (special entry in the index of your main repo referencing the SHA1 of the root tree of the subrepo)
You need to add:
git rm subrepoRootFolder # no trailing /
git commit -m "remove subrepo gitlink"
Then you can git add ., and all files within subrepoRootFolder will be (finally) added to your main repository. Then commit and push.
I need to migrate multiple repositories from SVN to Git under Windows. Part of the repositories has empty folders, they are critical for projects and these folders cannot be deleted without breaking the project.
I tried the git svn clone command with the keys --preserve-empty-dirs --placeholder-filename = .gitkeep but this does not work at all.
As a result, the folder is not added to the commit history - this is a big problem because it is impossible to updade to the old version. After full migration the folder is also not added.
I tried to make a crutch to the mechanism, but I do not understand how to make it correctly:
This code creates zero-size files that Git does not process:
for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do (fsutil file createnew %d/.gitkeep 0 && echo.>%%d/.gitkeep)
This code creates files with a size of 2 bytes:
for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do (echo.>%d/.gitkeep)
In both cases, there is a problem with the fact that files are created in all folders, and not just empty ones. In addition, I lack an understanding of how to exclude the .git folder from processing.
Please, help.
No way, but I wrote a crutch under Ubuntu 18.04, it works successfully in WSL:
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
What is the best way to remove branch references that no longer exist and delete local branches already merged for git repos in Windows command prompt (i.e. not using bash)?
This will first remove any remote tracking references that no longer exist and then proceed to enumerate and remove already merged local branches. The exception is that current, develop and master branches will be kept.
git fetch -p && for /f "tokens=1,2" %b in ('git branch --merged ^| findstr /v /c:"master" /c:"develop" /c:"*"') do (git branch -d %b)
I have a C:\Dev folder, where I have cloned multiple Mercurial repositories. How do I get a list of those, so I can then clone them on a different PC?
You will probably have to write a batch script to do that and then use the hg paths default in each directory.
Put the something along those line in a new .bat file and then run it in your C:\Dev directory :
FOR /D %%G in ("*") DO hg -r %%G paths default
It is been a long time since I didn't wrote a batch file and I don't have a Windows machine to test it on, so it may need some modifications in order to work.
Good luck !
so far I have used Tortoise SVN to commit and update folders under version control. When I commit I check "all" in the GUI dialog so that deletions as well as additions are committed.
Now I have more and more folders under version control and I would like to have a batch file for committing and updating all of them.
So far I have experimented with the command line and found this:
svn add . --force
svn commit -m"Adding missing files"
This adds new files but does not reflect any deletions.
Could you please help me with the batch files? It would make my work a lot easier but I am really too unexperienced with SVN/batch files to do this on my own...
I use Win7x64 and Tortoise SVN 1.7.12 with the command line extension.
Thank you!
I think I figured something out using gammay's and this input:
cd "C:\Users\User\Desktop"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\?"`) do svn add "%%i %%j"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\!"`) do svn delete "%%i %%j"
svn commit -m "Commit via Batch"
And
cd "C:\Users\User\Desktop"
svn update
and repeatedly for different paths!
Thank you :)
Firstly, which svn command line tools do you use? You can use CollabNet for 'svn' commands.
Secondly, to delete files, you need to checkout existing files from svn, then use svn delete and then svn commit.
Your question is not clear - if this doesn't answer your question, please provide a few more details.
Edited to answer asker's requirement (in comments below):
OK. What you want is a script which will find the new files in the folder and add them to SVN automatically and find deleted files in folder and delete them from SVN too. I can tell you this is a dangerous as undesired files can get added/deleted.
Still, if you want to go ahead with this script this is what the script can do:
Run svn status which displays missing (deleted) files and unknown (to be added) files
! FileA [Missing - deleted]
? FileD [Unknown - to be added]
Parse the output to find the ! files and run svn delete on these files
svn delete FileA
Parse the output to find the ? files and run svn add on these files
svn add FileD
svn commit
This commits the above deleted & added files and also any modifications.
If you do not want to commit modifications, commit individual added/deleted files