Answer the question
In order to leave comments, you need to log in
How to change commit comments from a file?
Guys hello! There is a task to change comments to commits in a certain branch.
There is a script which takes 2 values as old and new commit. Loops (while read -r line; do) accesses lines in file file.txt each time
The script itself:
#!/bin/bash
fille="$1"
#fille="fille.txt"
while read -r line; do
source=$(echo "$line" | awk 'BEGIN { FS = "," } { print $1} ');
target=$(echo "$line" | awk 'BEGIN { FS = "," } { print $2} ');
git filter-branch -f --msg-filter 'sed -e "s/'"$source"'/'"$target"'/g"'
done < "$file"
Answer the question
In order to leave comments, you need to log in
Please help me optimize this script.
#!/bin/bash
fille="$1"
cmd=
while read -r line; do
source=$(echo "$line" | awk 'BEGIN { FS = "," } { print $1} ');
target=$(echo "$line" | awk 'BEGIN { FS = "," } { print $2} ');
cmd="${cmd}s,$source,$target,g;"
done < "$file"
git filter-branch -f --msg-filter "sed -e '$cmd'"
But is it possible? Git only allows you to change the latest commits by collapsing them into 1 commit (amend).
Or you can completely create a new repo and transfer all the changes there one at a time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question