Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 62925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:33:08+00:00 2026-05-10T18:33:08+00:00

I have multiple branches of a project checked out, each under their own directory

  • 0

I have multiple branches of a project checked out, each under their own directory (pretty standard).

src/branch1/some/code/directories src/branch2/some/code/directories

I often find myself wanting to copy selected files from one branch to another. An example would be copying cvsignore files, or intellij module files. The pseudocommand for what I’m trying to do is ‘copy all files under branch1 matching PATTERN to branch2, preserving the relative path of the copied file’.

This question looks close to what I’m looking for, but I need an OS X/linux/unix solution.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:33:09+00:00Added an answer on May 10, 2026 at 6:33 pm

    Use ‘cp -r –parents’ command like this, in branch1 directory

    find . -name '.cvsignore' -exec cp -r --parents {} ../branch2/ \; 

    OR

    When in the src/ directory, run this script. You can get the variables from command line parameters if you want.

    SOURCE='branch1/' TARGET='branch2/' PATTERN='.cvsignore'  find $SOURCE -name $PATTERN | while read f ; do         FILEPATH=$(dirname $f | cut -d'/' -f2-)         FILENAME=$(basename $f)         DESTPATH=$TARGET/$FILEPATH;         if [ ! -d $DESTPATH ]                 then mkdir -p $DESTPATH         fi         cp $f $DESTPATH done 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SVN repository containing multiple top-level folders, one per project. Inside each
I have multiple but similar client-side iPhone apps, managed as branches in git (all
I have multiple active branches that I need to work on at the same
I'm working on a project with multiple branches with some other developers. In my
In a recent embedded project, we have used the following svn structure: project branches
In CVS we have on project with multiple directories in there. There is a
I have an SVN repository that has multiple projects inside of it, each one
We have multiple developers working on a project. We're employing a feature-branch method of
I have a project targeted to multiple platform. I have to change UI codes
I have a large Java app that is split up into multiple projects. Each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.