I am wondering if there is a way to take a file modification and move it to an ancestor of the current branch when the ancestor has multiple descendants. So in the picture, the master branch has a modified Visual Studio project file and I want to move the modification for that file to the ancestor commit titled merge branch 1.3.2new (I'll create a branch if necessary). Then all the descendants of that branch, i.e. symlinks/master/job_log_#files_backupsize/snapshot_archive_target_not_found/scandir_fix/miscellaneous inherit the change and I don't have to modify each branch individually with the desired change. Currently all the descendants do not have any modifications of the Visual Studio project file so there wouldn't be any merge conflicts.
Asked
Active
Viewed 35 times
1 Answers
0
Then all the descendants of that commit/branch, i.e.
symlinks/master/job_log_#files_backupsize/snapshot_archive_target_not_found/scandir_fix/miscellaneous
inherit the change and I don't have to modify each branch individually with the desired change.
They wont inherit the change unless you rebase them all, one by one, on top of the new 1.3.2new branch HEAD.
Which is painful to do.
I would rather apply a git patch to each of those branches in order to report that file modification.
git diff <commit-hash> <path-to-file> > mypatch.patch
git switch <branch-1>
git apply mypatch.patch
git commit -m "Apply patch to branch-1"
# repeat for other branches

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Thanks VonC, any way of using git command line to overwrite the blob for the Visual Studio project file in the ancestor branch? – riverofwind Feb 19 '23 at 20:57
-
@riverofwind I suppose [`git restore`, as in here](https://stackoverflow.com/a/57676529/6309): that will override a blob from command-line. – VonC Feb 19 '23 at 21:12
-
Just tried the command, it didn't overwrite the blob just grabbed the file from the source commit and added it to the working directory. I'm thinking your initial approach is the way to go. – riverofwind Feb 20 '23 at 21:50