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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:25:58+00:00 2026-05-29T11:25:58+00:00

Suppose I have a git repos that contains original.script . At some point, I

  • 0

Suppose I have a git repos that contains original.script. At some point, I want to do something similar to original.script, so I decide to use it as a starting point for a new script modified.script:

% git branch before-cp
% cp original.script modified.script
% git add modified.script
% git commit -m "creating a copy to modify"
% vim modified.script #...
% git add modified.script
% git commit -m "made some modifications"

Now, at some point, I discover a bug in original.script. I can just patch original.script, but that doesn’t help modified.script which may retain the bug. I’d like to fix original.script back before it was copied, doing something like:

% git checkout before-cp
% vim original.script #...
% git add original.script
% git commit -m "fixing a bug in original before I start copying it"
% git checkout master
% git rebase before-cp

But this doesn’t work the way I want it to. The rebased “creating a copy to modify” commit still contains a copy of modified.script that’s identical to the unpatched version of original.script (from before-cp^).

I’m ok with my first attempt being the wrong way to do it – but is there a right way to do it? To retroactively patch a file so that future copies copy the patched version? Or am I going to have to manually patch modified.script (and any other files in the copy-subtree of original.script).

  • 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-29T11:25:59+00:00Added an answer on May 29, 2026 at 11:25 am

    You have to manually patch modified.script. When you copied original.script to modified.script, the new commit simply records the fact that you created modified.script with a particular set of file contents. When looking at the diffstat, git will tell you that you copied original.script to create modified.script but it inferred that, the commit itself didn’t actually record that fact. If you retroactively modify original.script and try to rebase your commit that creates modified.script on top of that, it will re-create the exact same modified.script that you had before, and if you diffstat the commit, it will look like you copied original.script and then made some changes (effectively reverting your fix) before actually committing it.

    The only solution you have is to apply the same patch to modified.script.

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

Sidebar

Related Questions

I have a git repository with some commits in it. I want to reproduce
I have something strange going on with some of my repos .. Xcode seems
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have a table called Companies that has a DepartmentID column. There's also
Backround: Suppose I have the following Git URLs (hosted on github) http://github.com/mikl/drupal.git git://github.com/mikl/drupal.git (Git
Suppose I have a project implemented in a specific programming language whose use is
I use git for my source management, I have a local repository on my
Suppose I have 5 local commits. I want to push only 2 of them

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.