Simply copy the file, add and commit it:
cp dir1/A.txt dir2/A.txt
git add dir2/A.txt
git commit -m "Duplicated file from dir1/ to dir2/"
Then the following commands will show the full pre-copy history:
git log --follow dir2/A.txt
To see inherited line-by-line annotations from the original file use this:
git blame -C -C -C dir2/A.txt
Git does not track copies at commit-time, instead it detects them when inspecting history with e.g. git blame
and git log
.
Most of this information comes from the answers here: Record file copy operation with Git