简体   繁体   中英

How can I make a change to changes in a git branch?

I have a git branch that I've made some code changes on. However, I've decided that I need to change the command I've added ( static_cast ) to a newer command ( narrow_cast ).

I made a lot of these changes so what I want to do is write a script that:

  1. Identifies all the changes between the branch and trunk.
  2. Replace the use of static_cast to narrow_cast in these changes.
  3. Writes the result back to the branch.

Is this possible? If so, how?

did you try :

  • git diff "tag from which you branched"

this will list all your changes , this is also kind of a patch that you can apply again to your code

  • git diff "tag from which you branched" > redo_all.patch

in redo_all.patch change the static_cast to narrow_cast (edit replace all .. be careful with replace all)

then create a new branch at same start point

  • git apply redo_all.patch

at this point you have a new branch with the correct modifications

advantage of this : you have your old modif on a branch and the new ons on another branch... then when you checked everything is ok you can work to change the branches names

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM