Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

I would like to rename/move a project subtree in Git moving it from

/project/xyz

to

/components/xyz

If I use a plain git mv project components, then all the commit history for the Xyz project gets lost. Is there a way to move this such that the history is maintained?

1 Answer

0 votes
by (50.2k points)

Git will detect the renames, so it doesn’t matter whether you use git mv or just mv.

And the log command with --follow option will help your git to continue the history before the rename.

For full history use this command:

git log --follow ./path/to/file

Reference:  https://git-scm.com/docs/git-log#Documentation/git-log.txt---follow

Browse Categories

...