Git file rename. Is history available on the CMD line, but not on the github interface?

There were many excellent posts on how to save history when renaming files and folders in Git.


This works in the git command line interface:

#if you don't modify oldname.cpp or newname.cpp, git will understand your rename git mv old.cpp new.cpp git commit -am "renamed old.cpp -> new.cpp" git log new.cpp #only shows the new commit git log --follow new.cpp #shows ALL the history of old.cpp and new.cpp 

Great, so the --follow command allows us to get the whole history of new.cpp after renaming it. This works great on the command line interface for Git.


But, in the github web interface, the history of old.cpp not displayed for new.cpp . This is a problem because many of my team members view their github accounts as part of their resume. If their commits do not appear on github after renaming files, they lose renewal points. After the main reorganization of the file / directory, the contributor may not have any visible commit on the repo.

How to get the full file history displayed in the github web interface (e.g. git log --follow ) after renaming files?

Or am I stuck by never renaming anything unless I want random github users to never see old commits?

+6
source share
1 answer

As you probably know from these three questions that you have linked, there is nothing in Git that tracks file movement. For Git, this is just a file that is deleted, and another file is added. Only the interface does some recognition of file movements based on content similarity. Thus, if GitHub does not track changes to a file that may have been ported earlier, you really cannot do anything but ask GitHub to work on it.

At the same time, your statement that moving the file will cause the contributor to be without visible commits is false. Yes, if I look at the history of one file that was previously deleted, then it may seem to him, but, as you could now, Git does not forget about what happened in the repository. And the journal for the repository will still contain every single message visible from this thread. And that, obviously, also includes commits that happened before the files were moved (since Git tracks content, not changes). You can usually get the commit log at https://github.com/<user>/<project>/commits/<branch> .

And here is another point: only those commits that are visible from this branch are included in the log. Therefore, if you work with several branches, all this is stupid anyway. If you want to get an idea of ​​how the contributor is working on the project, you should use the project graphs at https://github.com/<user>/<project>/graphs/contributors .

But, of course, measuring the amount of fixation is not a good indicator (just like the LOC ratio ).

+4
source

Source: https://habr.com/ru/post/954965/


All Articles