refactoring - How to move function declaration to another file yet retain Git history? -


i refactoring single-file php script declare functions , classes in separate files. how 1 move block of code 1 file file yet preserve git history each individual line? ability use @ least git blame on code. comparing older versions helpful.

note not interested in 'workaround' solutions require additional commands or flags (such --follow) on code view 'old' history, person viewing history have know file needs special treatment. looking solution writes necessary metadata such normal git commands such blame, log, diff, , such 'just work' without presenting them additional flags or arguments.

i have read quite few posts looking solutions similar problems, none address issue of git blame on individual lines. 1 solution think work copy file , entire history, work off of that. however, question remains without satisfactory answer.

warning: assumes rewriting history acceptable. not use unless know implications of rewriting history.

to split file multiple files while maintaining history use git filter-branch:

git filter-branch --tree-filter 'if [ -f original.php ];      echo part1.php part2.php part3.php | xargs -n 1 cp original.php; fi' head 

then delete lines not want each file (leaving desired functions , classes) , commit result!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -