<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dilip Raj Baral</title>
    <description>The latest articles on DEV Community by Dilip Raj Baral (@rajbdilip).</description>
    <link>https://dev.to/rajbdilip</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F11426%2F5624277.jpeg</url>
      <title>DEV Community: Dilip Raj Baral</title>
      <link>https://dev.to/rajbdilip</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajbdilip"/>
    <language>en</language>
    <item>
      <title>Quick SVN guide for Git users; SVN: The Git Way</title>
      <dc:creator>Dilip Raj Baral</dc:creator>
      <pubDate>Sun, 19 Aug 2018 19:33:02 +0000</pubDate>
      <link>https://dev.to/rajbdilip/quick-svn-guide-for-git-users-svn-the-git-way-26al</link>
      <guid>https://dev.to/rajbdilip/quick-svn-guide-for-git-users-svn-the-git-way-26al</guid>
      <description>&lt;p&gt;This post was first published on &lt;a href="https://diliprajbaral.com/2018/01/13/quick-svn-guide-for-git-users-svn-the-git-way/" rel="noopener noreferrer"&gt;Quick SVN guide for Git users; SVN: The Git Way&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Why would a Git user want to switch to SVN, you ask?&lt;/p&gt;

&lt;p&gt;Well, sometimes you just don't have a choice. Imagine working on a project that has been maintained in SVN since a decade. "But migrating an SVN codebase to Git is not a big deal at all." But there is stuff like CI/CD integrations to worry about too. That isn't a really big deal either but sometimes people take "Don't fix what ain't break." a little too seriously.&lt;/p&gt;

&lt;p&gt;Reasons aside, having a good Version Control System (Distributed VCS for that matter) concepts, I didn't want to go SVN guides from the scratch to start with. While there were plenty of resources on the web regarding SVN to Git migration, I couldn't' find a quick and concise guide that would help me work with an SVN repo right away. If you are like me, you will find this article helpful. The following steps show you how can work with SVN the Git way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloning a new repo
&lt;/h3&gt;

&lt;p&gt;Checking out a repo is similar to how we do it in Git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn checkout &amp;lt;path-to-your-repo-branch&amp;gt; &amp;lt;path-to-checkout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;The following checks out your code to your current working directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ svn checkout https://mysvnrepo.com/myrepo/trunk .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a new topic branch
&lt;/h3&gt;

&lt;p&gt;In SVN, branches (and tags) are nothing but a simply a copy of one branch. A literal copy-paste of the files, unlike pointer to commits in Git. This fact took me a while to digest and get used to.&lt;/p&gt;

&lt;p&gt;The following commands are SVN equivalent to git checkout -b branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn copy &amp;lt;path-to-a-branch&amp;gt; &amp;lt;path-for-new-branch&amp;gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn copy &lt;span class="nt"&gt;--parents&lt;/span&gt; https://mysvnrepo.com/myrepo/trunk https://mysvnrepo.com/myrepo/branches/feature-branch
&lt;span class="nv"&gt;$ &lt;/span&gt;svn switch https://mysvnrepo.com/myrepo/branches/feature-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Working on the repo
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Adding new files
&lt;/h4&gt;

&lt;p&gt;To add new files, you would use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn add &amp;lt;path-to-file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As for modified files, we don't need to add them. We can straight away commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To commit only specific files, we need to list files after the commit message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit message"&lt;/span&gt; &amp;lt;path-to-file-1&amp;gt; &amp;lt;path-to-file-2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we want to commit a single file, we can do the following too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn commit &amp;lt;path-to-file&amp;gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Checking out new changes
&lt;/h3&gt;

&lt;p&gt;The following is the SVN equivalent to git fetch &amp;amp;&amp;amp; git merge or git pull.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Merging your feature branch to trunk
&lt;/h3&gt;

&lt;p&gt;Merging a branch in SVN is similar to how we do it in Git.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn merge &amp;lt;path-to-branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn update
&lt;span class="nv"&gt;$ &lt;/span&gt;svn switch https://mysvnrepo.com/myrepo/trunk
&lt;span class="nv"&gt;$ &lt;/span&gt;svn update
&lt;span class="nv"&gt;$ &lt;/span&gt;svn merge https://mysvnrepo.com/myrepo/branches/feature-branch
&lt;span class="nv"&gt;$ &lt;/span&gt;svn commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Merge feature branch to trunk"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deleting feature branch after merging
&lt;/h3&gt;

&lt;p&gt;To delete a feature branch (or any branch for that matter), svn delete is used.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;svn delete https://mysvnrepo.com/myrepo/branches/feature-branch &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Delete feature branch after merging"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>svn</category>
      <category>git</category>
      <category>vcs</category>
    </item>
  </channel>
</rss>
