Git

How to Clone Local SVN Repository in Git?

While working in the Git environment, cloning an SVN repository into Git typically involves using a tool like git-svn, which allows users to interact with SVN repositories using Git commands. This tool can fetch the SVN history and convert it into Git commits. It enables users to work with the project using Git’s familiar interface and features.

This write-up will state the method for cloning a local SVN repository in Git.

How to Clone Local SVN Repository in Git?

To clone the local SVN repository in Git, try out the below-stated instructions:

  • Launch “VisualSVN Server” from the Startup menu.
  • Navigate toward the repositories.
  • Right-click on the selected repository and copy the URL on the clipboard.
  • Open the “Git Bash” utility on your local system.
  • Go toward the local Git directory using the “cd” command.
  • Clone the SVN repository with the help of the “git clone” command.
  • Lastly, verify the cloned SVN repository by executing the “ls” command.

Step 1: Launch SVN Server

Initially, launch the “VisualSVN Server” on your system by using the “Startup” menu:

Step 2: Navigate to the Local SVN Repository

Next, go toward the “Repositories” to view the available local SVN repositories. The below-given image indicates that the available repositories have been launched on the SVN window:

Step 3: Copy URL of the SVN Repository

After that, right-click on your preferred SVN repository which you want to clone in Git. A small prompt window will appear on the screen, copy the URL of the selected repository on the clipboard for further use. In our case, copied URL is stated below:

https://DESKTOP-72QOGVA/svn/firstsvnRepo/

Step 4: Open Git Bash

Now, open the “Git Bash” environment from the “Startup” menu:

Step 5: Navigate to Local Git Directory

Run the “cd” command along with the path of the Git local directory and redirect to it:

cd "C:\Users\user\Git\newRepo"

Step 6: Clone SVN Repository in Git

Now, clone the SVN local repository in Git by running the “git clone” command along with the copied URL of the SVN local repository:

git svn clone file:https://DESKTOP-72QOGVA/svn/firstsvnRepo/

The resultant image indicates that the SVN repository has been cloned in Git local directory successfully:

Step 7: Verify SVN Cloned Repository

Execute the “ls” command to check whether the cloned repository is available in the Git directory or not:

ls

The below-stated output determines that the SVN repository is available as a subdirectory in the Git local directory:

Note: It is important to note that cloning an SVN repository into Git is a one-time process to establish the initial Git repository. After completing the cloning process, the SVN repository and the Git repository will exist as separate entities, and any further changes made in one repository will not automatically reflect in the other.

That’s all about cloning the local SVN repository in Git.

Conclusion

To clone the local SVN repository in Git, first, launch “VisualSVN Server” and navigate toward the repositories. Then, copy the URL of the selected repository to the clipboard. After that, open the “Git Bash” environment and move to the local Git directory. Next, clone the SVN repository with the help of the “git clone” command. Lastly, verify the cloned SVN repository by executing the “ls” command. This guide provided a way of cloning the SVN local repository in Git.

About the author

Hafsa Javed