0

Is there a way for a Visual Studio user to copy a bunch of files from one location to another and keep the history of both versions?

I found the answer https://stackoverflow.com/a/44036771/1520078, which may solve the problem for single files, but I want to copy hundreds of files, preferredly not having to rename each single one.

LionAM
  • 1,271
  • 10
  • 28
  • In git, the commits _are the history_. Maybe to do this, clone the repo, rename the files, then add and commit them? – evolutionxbox Jul 20 '21 at 10:42
  • I'm not sure how this could retain the history of both versions. Every time I try to add some files, either the new file or the old file has no history any more... – LionAM Jul 20 '21 at 11:45
  • 1
    In git files do not have history. A commit is a snapshot of the _entire repo_ – evolutionxbox Jul 20 '21 at 13:26

1 Answers1

-1

As noted in comments, files in Git do not have history. History, in Git, is nothing but commits: the commits are the history, and each commit has a full copy of every file.

What this means is that any viewer that purports to show "file history" is lying. It may do a very good job of lying, by using commit history to find exactly what you mean by "file history", or it may do a poor job of lying, by showing you something you don't mean at all. But it definitely has to lie because there is no file history, there is only commits-as-history.

Each Git commit viewer has its own method(s) of lying to produce file history, since users like to see file history. But each viewer tends to do it a little differently. Find a viewer you like, and use that one.

torek
  • 448,244
  • 59
  • 642
  • 775
  • I understand your point. This is explained in the linked answer, too. But it doesn't matter to me, as long as I can see when the file has been changed the last time or who did a change to some line. The solution in the linked answer works for me as expected, but it is just inconvenient having to rename the files one by one and doing multiple commits, branches and merges. I was hoping that there existed an automated solution. – LionAM Jul 22 '21 at 12:04
  • There isn't as far as I know, but Git is a *programmable* VCS, that requires (and therefore comes with) a shell that can manipulate files. So you could just write your own script to automate it. – torek Jul 22 '21 at 19:15
  • I think that it is a bit picky to say file history is _lying_. As long as the tool can do the job it does not really matter what the actual underlying machinery is. Otherwise stuff such as virtualization or emulation are also _lying_... – victor6510 Jun 24 '22 at 03:22
  • @victor6510: if an emulator *completely* emulates everything *perfectly* (down to the timing, and changing your living room or office furniture back to how it was in the 1980s or whatever) then it's no longer an emulator, but we don't say that an emulator *is* a zed-ecks-81 or whatever, we say it's *emulating* it. If a viewer program tells you that it can show you a filtered Git history so that it's *about* a file, and shows that, then it's good. But if it tells you "I can show you Git's file history" then it's ... stretching the truth at best. – torek Jun 24 '22 at 23:43