DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Building Call Graphs for Code Exploration Using Tree-Sitter
  • Two-Pass Huffman in Blocks of 2 Symbols: Golang Implementation
  • Implementing LSM Trees in Golang: A Comprehensive Guide
  • Efficient and Fault-Tolerant Solutions for Distributed Mutual Exclusion

Trending

  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data
  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice

SVN. Update a single file without checking out the entire source tree

By 
Viktor Sadovnikov user avatar
Viktor Sadovnikov
·
Dec. 02, 13 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
11.9K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes, especially when you work cross various projects, you need to modify a single file in a project. A good  example for this updating pom.xml by adding description, name, SCM or CI sections.

However majority of UI tools do not provide a possibility to extract a single file, avoiding checking out all its siblings recursively. Commands of CLI enable this, but they are not well known.

The idea is to checkout the containing folder with ‘empty’ depth and then update the file you are interested in. For simplicity of use, I wrote a shell script, which take the URI to the file is SVN, and extracts it to the current directory. The URI of the file can be copied from a browser. The script is also available in Bitbucket

#!/bin/sh
# Empties current directory and extracts single file/folder from svn
# see complete description on http://jv-ration.com/2013/11/modify-single-file-in-svn-tree

die () {
    echo >&2 "$@"
    exit 1
}

usage=$"This scripts extract single file/folder from SVN repository into the current directory,\n\
allowing to modify it locally without extracting all other sibling files and directories\n\
\n\
$0 svn_uri\n\
"

[ "$#" -ge 1 ] || die "SVN URI is not provided. $usage"
fullUri=$1

# Testing is svn CLI is present
svnRun=`which svn 2> /dev/null`
if [ ! $svnRun ]
then
  die "svn CLI is not found on PATH"
fi  

# determine parent folder and file from the give URI
svnFile=${fullUri##*/}
svnParent=${fullUri%%/${svnFile}}

# remove .svn and the file if they exist
rm -rf .svn
rm -f $svnFile

# extract the file
svn checkout -q --depth=empty $svnParent .
svn update $svnFile

echo "\n\
After $svnFile is changed locally commit it using\n\
  svn commit -m \"your update description\""
Tree (data structure)

Opinions expressed by DZone contributors are their own.

Related

  • Building Call Graphs for Code Exploration Using Tree-Sitter
  • Two-Pass Huffman in Blocks of 2 Symbols: Golang Implementation
  • Implementing LSM Trees in Golang: A Comprehensive Guide
  • Efficient and Fault-Tolerant Solutions for Distributed Mutual Exclusion

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!