Reputation: 3
StackOverflow community,
I have a git repository with this hierarchy:
(git-tree-root)
software
development
project1
project2
...
projectX
operational
project1
project2
...
projectX
and I want to get a simpler hierarchy,
(git-tree-root)
dev
project1
project2
...
projectX
op
project1
project2
...
projectX
It is crucial that I maintain the file's git history. My first thought is to do:
git mv -kr software/development/* dev/
and
git mv -kr software/operational/* op/
k flag is to ignore possible errors when moving files and the r flag is to move all files and folders recursively found inside the corresponding folders (development and operational). Then git add, and git commit changes.
Also, I want to make sure that in case there are users with files still "un-pushed" to the repo, they don't push them to the old hierarchy. Git should take care of this whenever they git pull my changes, correct?
It is important I get this right, so I would appreciate your help. Thanks in advance eveyone.
Upvotes: 0
Views: 99
Reputation: 13377
It should be as simple as
git mv software/development dev
git mv software/operational op
and if there is other cruft in software
that you do not need anymore
git rm -r software
and then
git commit
Note that Git does not store file identities. "File history" is only reconstructed from the commit history. git log --follow some/file
may help as long as you are investigating the history of just one file, but you may run into problems when the file contents have diverged sufficiently and you are comparing states before and after this event, because Git won't be able to correlate the two states to a "singe file".
Upvotes: 1