tags:

views:

32

answers:

1

I have a codebase of Javascript files that I use to drive a Web site. To synchronize the many files in deployment, I name the files with an appended version number. I have a "master" file that contains current version numbers for the different components. This is used to generate the script tags in the HTML file.

I have the codebase set up as a Git repository. But because of the way I am managing this with version numbers, any time I deploy a new file set, I issue

git mv file.old-vers.js file.new-vers.js

This works in general, except that Git treats this as a complete new file, and so I lose the history of changes.

Question: is there a way to tell Git to maintain continuity? (i.e. that even though the file name has changed, that it remains the same entity)

A: 

git log can track renames. Try git log --follow path/to/file.

August Lilleaas
Thanks for the info, but I don't want to track the history of the filename changes, but to have Git treat the file in a continuous manner. Currently, when I do the "git mv", Git removes the old-version-named file and adds the new-version-named file. The newly added file has all its lines added, so I've lost the history of changes. Which makes using Git sorta pointless, as I can achieve the current net effect by just backing up my files. What I need is a way to tell Git to rename the file but not consider it a new entity.
Zhami
Ah, I seem to have misunderstood the effect of your suggestion. I just found a question similar to mine here on Stack Overflow: http://stackoverflow.com/questions/2314652/is-it-possible-to-move-rename-files-in-git-and-maintain-their-history
Zhami
Just tried this and it didn't work - Git didn't assemble the history of the file, all I got was a single entry for the latest commit using the current file name.
Zhami
@Zhami Did you try `git log --follow `?
Rudi
Ah, my error (Git newbie) -- got it working now.
Zhami