Skip to content

Bash script - Split commits for specific folder modifications #22417

Discussion options

You must be logged in to vote

I’ve done things like this in various ways…

You can do something like:

dest=main
branch=new-feature
git checkout $dest
for directory in translations src .; do 
  git diff $dest..$branch -- $directory | patch -p1
  git commit -m "$directory: $branch" $directory
done

(You’ll want to read about .. to make sure it’s doing what you want.)

Note: You need to be careful about additions and removals, the above will do the wrong thing (and mode changes for that matter).

You could also play w/ git checkout + git reset instead of git diff if you’re being adventurous.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants