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 7615259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:36:06+00:00 2026-05-31T02:36:06+00:00

I’m a newbie to git, and I do understand how git cherry-pick works, but

  • 0

I’m a newbie to git, and I do understand how git cherry-pick works, but here is my problem:

Recently, someone in my team, changed the directory structure in master, but not the directory structure in another branch.

Now, when I do make changes to my code in branch, I want to bring them (cherry-pick) into master. This was fine until the directory structures in both master and the branch were same.

topDir/some/subdir/file — master
topDir/some/other/subdir/file — branch

file, whose changes are to be brought into master is the same, but not the directory structure it is contained in. When I try to do a cherry-pick the usual way, I get an error along the lines of:

git checkout master
git cherry-pick commit
error: pathspec topDir/some/other/subdir/file does not exist

Now, what is the best way to go about cherry-picking in this scenario? Any pointers are highly appreciated.


OK. I just noticed that, in the same scenario, when I do a cherry-pick, git is smart enough to actually pick one of the files correctly from the commit, but does not recognize the other.

To use the same example I mentioned in my original post: In the same commit,
topDir/some/subdir/file1,
topDir/some/subdir1/file2.

I go to master, which has “file1” and “file2”, just in a different dir structure:
topDir/src/some/subdir/file1
topDir/src/some/subdir1/file2.

Now, if I do a cherry-pick, git is intelligent enough to pick up the changes in file1, even though this is in a different dir structure, but doesn’t pick up the changes for file2. Any pointers? If anyone wants me to be more clear, I’ll be happy to.

So, what I did to workaround the problem was do a cherry-pick, manually change the one git did not pick up, and “git commit -C .

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-31T02:36:07+00:00Added an answer on May 31, 2026 at 2:36 am

    Happy to help 🙂 if the one in master will be the permanent way, I would fix the file structure in the topic branch to match master, commit to the branch, *then merge the changes into master, not cherry-pick. As in

    git checkout branch
    mv other/subdir/file subdir/file
    git status
    // git add and git rm to get the commit proper
    git commit -m "fixing file struct"
    git checkout master
    git merge branch
    

    Really though, it depends on what the use cases of the files are, and what you want to be in the master branch, which is much more a your company specific question, not so much a technical problem anyone here can answer for you 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.