How to Checkout and Update Files from Your SVN Repository to a Local Directory Using Command Line

How to Checkout and Update Files from Your SVN Repository to a Local Directory Using Command Line

Step 1: Install and Set Up SVN

Make sure SVN (Subversion) is installed and properly configured on your computer. You can check if it’s installed by running the following command:

svn –version

If SVN isn’t installed, download and install it from the SVN official site.

Step 2: Navigate to Your Plugin Directory

Once SVN is installed, open Command Prompt (Windows) or Terminal (macOS/Linux) and navigate to the folder where your plugin resides. For example, your plugin is located at:

cd C:\smartupworld\plugins\smartupworld-video-modal

Ensure you’re in the plugin directory where your trunk folder and other plugin files are stored.

Step 3: Check the Status of the SVN Working Copy

Before committing any changes, you can check the status of your working copy (which files are modified, added, or deleted) by running:

svn status

This will list all the files and folders in your working copy and indicate whether they have been modified (M), added (A), or deleted (D).

Example Output:

M trunk/assets/style.css
A trunk/assets/new-file.css
  • M means the style.css file has been modified.

  • A means new-file.css has been added and is pending commit.

Step 4: Modify an Existing File (e.g., style.css)

If you’re modifying an existing file (e.g., style.css), here’s how you do it:

  1. Open the file in your text editor (e.g., Visual Studio Code, Sublime Text).

  2. Make the necessary changes to the file.

  3. Save the file.

Once saved, you don’t need to add the file again since it’s already tracked by SVN.

Step 5: Add New Files (e.g., new-file.css)

If you add a new file (like new-file.css), you need to tell SVN to track this file using svn add.

  1. Create or place the new file in the correct directory (e.g., trunk/assets/new-file.css).

  2. Add the file to SVN:

svn add trunk/assets/new-file.css
  1. Check the status again to make sure the new file is added:

svn status

Now, you should see A next to the new file (new-file.css), indicating that it’s ready to be committed.

Step 6: Commit Your Changes (For Existing and New Files)

After modifying existing files or adding new files, you need to commit them to the SVN repository.

  1. Commit all changes (including modifications and new files) by running:

svn commit -m “Updated style.css and added new-file.css”
  • The -m flag is for the commit message, where you should describe what changes were made (e.g., “Updated CSS for video modal”).

  • SVN will prompt you to enter your credentials (if you haven’t configured them already).

  1. Wait for the confirmation: After running the commit command, SVN will process the files and upload your changes to the repository. You should see a confirmation like this:

    Sending trunk/assets/style.css
    Adding trunk/assets/new-file.css
    Transmitting file data .done
    Committed revision 1234.

    This means your changes have been successfully committed.

Step 7: Create a Tag for a New Version (Optional)

Once your changes are committed, you might want to create a version tag for the plugin, especially if you’re preparing a new release. Tags represent stable versions of your plugin.

Tagging the New Version:

If you’ve made significant changes (like adding a new feature or updating styles), and you want to release a new version (e.g., version 1.3.0), you can create a tag for that version.

  1. Create a tag for the new version:

svn copy https://plugins.svn.wordpress.org/smartupworld-video-modal/trunk https://plugins.svn.wordpress.org/smartupworld-video-modal/tags/1.3.0 -m “Tagging version 1.3.0”
  • This command creates a copy of the trunk folder and saves it as a new version under tags/1.3.0.

  • The -m flag is for the commit message, which should describe the version being tagged (e.g., “Tagging version 1.3.0”).

  1. Verify the tag by browsing to the WordPress plugin repository. You should now see a folder for the new version (1.3.0).

Step 8: Verify and Check the Commit

After committing and tagging, it’s a good idea to verify that your changes were applied correctly.

  1. Check the commit history with:

svn log

This will display a list of commits, showing the most recent ones along with commit messages and revision numbers.

  1. Check the updated version in WordPress:

    • Go to the WordPress Plugin Repository.

    • Search for your plugin (smartupworld-video-modal).

    • Ensure that the latest version is updated and includes your changes.

Step 9: Update the Plugin in WordPress

If your plugin is already installed on a WordPress site, you can go to Dashboard > Updates and click Check Again. If a new version is available (e.g., 1.3.0), you can update it to reflect your changes.

Step 10: Troubleshoot Common Issues

  1. Changes Not Showing Up:

    • Clear cache: If you have caching plugins in WordPress (like W3 Total Cache or WP Super Cache), make sure to clear the cache.

    • Browser Cache: Clear your browser cache or do a hard refresh (Ctrl + F5).

  2. Error Committing:

    • Permissions issue: Make sure you have commit access to the repository.

    • Uncommitted Changes: If SVN says you have uncommitted changes, make sure all modified files are committed before tagging or pushing new changes.

Final Recap of Steps:

  1. Navigate to the plugin directory (cd command).

  2. Check status (svn status).

  3. Modify existing files (e.g., style.css) or add new files (e.g., new-file.css).

  4. Commit changes (svn commit).

  5. Tag a new version (optional) for releases (svn copy).

  6. Verify the commit and ensure everything is reflected in WordPress.

Conclusion

This guide covers the entire process of:

  • Adding new files (e.g., new CSS files).

  • Updating existing files (e.g., modifying style.css).

  • Committing your changes to SVN.

  • Tagging a version to mark a stable release.

  • Verifying that the changes are reflected on WordPress.

Al Mahbub Khan
Written by Al Mahbub Khan Full-Stack Developer & Adobe Certified Magento Developer

Full-stack developer at Scylla Technologies (USA), working remotely from Bangladesh. Adobe Certified Magento Developer.

Leave a Reply

Your email address will not be published. Required fields are marked *