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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:47:18+00:00 2026-05-30T21:47:18+00:00

I have a project I’ve been working on some experimental changes. To a sub-project

  • 0

I have a project I’ve been working on some experimental changes. To a sub-project in directory A. However, in the master branch of the project the sub-project has moved to so a separate directory, directory B.

I have about 10 commits I want to effectively cherry-pick into master, but how can I tell git to put the old directory into the new one?

Later
I tried to cherry pick because I wanted to only introduce my changes and keep the history clean. It’s not just file moves. I’ve also added new classes as well. It didn’t detect all of the moves either.(the first file that comes to mind is pom.xml)

  • 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-30T21:47:19+00:00Added an answer on May 30, 2026 at 9:47 pm

    You can convert these commits to patches, edit the patches manually (substituting old paths with new paths) and then apply.

    $ git init
    Initialized empty Git repository in /tmp/gitt/.git/
    $ mkdir olddir
    $ cp /home/vi/code/_/ucontext.cpp olddir/ucontext.cpp
    $ git add .
    $ git commit -m "initial commit"
    [master (root-commit) c0bf371] initial commit
     1 files changed, 97 insertions(+), 0 deletions(-)
     create mode 100644 olddir/ucontext.cpp
    
    $ printf '22\na\n// Sup, /git/!\n.\nw\nq\n' | ed olddir/ucontext.cpp
    1983
        if (!stacks) { stacks = stacks3; }
    1998
    $ git commit -am 'sample commit'
    [master 83940c9] sample commit
     1 files changed, 1 insertions(+), 0 deletions(-)
    $ printf '33\nd\nw\nq\n' | ed olddir/ucontext.cpp
    1998
        }else{
    1990
    $ git commit -am 'sample commit 2'
    [master 6599932] sample commit 2
     1 files changed, 0 insertions(+), 1 deletions(-)
    
    $ git format-patch HEAD~2 --stdout > saved-commites.patch
    $ git reset --hard HEAD~2
    HEAD is now at c0bf371 initial commit
    $ git mv olddir newdir
    $ git commit -m 'rename dir'
    [master bd8a77e] rename dir
     1 files changed, 0 insertions(+), 0 deletions(-)
     rename {olddir => newdir}/ucontext.cpp (100%)
    
    $ sed -i.bak 's!\([ab]/\)olddir/!\1newdir/!g' saved-commites.patch
    $ git am saved-commites.patch
    Applying: sample commit
    Applying: sample commit 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have project that I'm working on that is going to require a webserver.
I have a project that I'm currently working on but it currently only supports
I have a project where a .master page was created without a code behind
Problem domain We have Projects and Milestones Once created, a Milestone has a Project
I have project of following struct A CMakeLists.txt B CMakeLists.txt C CMakeLists.txt I directory
I have project which is currently working and was developed long time back on
I have some project with file: src/Test.cpp . Now I make subproject for it
In the Eclipse environment I have project A. A has dependencies to projects or
I have university Internet. It has IP, let's say 220.81.184.12. I have project named
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net

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.