3

I make a sort of rebranding and rename all root folders inside the project. Smartgit sees all files as missing and untracked. When I commit some of them are marked as renamed in log but a lot of them not. I don't want to lose the connection with fork source for these files. I don't change anything inside the files, just rename all root folders and some files inside.

I perform rename via Total Commander mass rename functionallity. It would take a long time to rename those manually with git mv.

What can I do to help git to detect the renames?

UPDATE

I found out that it detects renaming only on recently added files which did not exist in the fork source.

UPDATE2

I created 2 clones to test this behavior.

  1. Changed one file, commit and push in clone 1.
  2. Performed rename in clone 2, commit, pull.

And now I have a rebase conflict in clone 2. Seems like it actually detects rename but why then conflict?

enter image description here

Vlad
  • 3,001
  • 1
  • 22
  • 52
  • so you do this : create a git repository with your sources, import some code (with copy/paste or something) in your repository, mass rename, try to commit. That's it ? – mithrop Oct 28 '14 at 18:14

1 Answers1

1

Git does not track renames at commit time[1], but always calculates them on the fly. Hence, there is nothing you can do about it. See also:

https://stackoverflow.com/a/7941544/241453

[1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_does_Git_not_.22track.22_renames.3F

Community
  • 1
  • 1
mstrap
  • 16,808
  • 10
  • 56
  • 86
  • What matters is whether I can rebase afterwise on new fork commits. I found out that git detects renaming only on recently added files which did not exist in the fork source. – Vlad Oct 28 '14 at 15:57
  • What exactly do you mean by 'fork source'? Can you give some example for which rename detection does not work as expected? – mstrap Oct 28 '14 at 19:46
  • I forked a github repository, made a few commits and now I want to rename whole project in next commit. But the problem is that if git does not show renames in log I think it will not rebase correctly when I pull new commits from the original project. If some files were changed there then those changes won't be seen in my forked project because git thinks there are new files and deleted files but not renamed. – Vlad Oct 28 '14 at 22:50
  • That could actually happen. On the other hand, if files really just were renamed and content hasn't changed, all of them should show up as "renamed" in the Log. Anyway, it's probably no good idea to fork a GitHub repository and then rename everything, if you want to further sync from that repository. – mstrap Oct 29 '14 at 08:38
  • I created 2 clones to test this. Changed one file, commit and push in clone 1. Performed rename in clone 2, commit, pull. And now I have a rebase conflict in clone 2. Why does not it work? – Vlad Oct 29 '14 at 09:53
  • I added a screenshot, see the question. – Vlad Oct 29 '14 at 10:09
  • Does 'git log' display renames or additions/removals, too? Do the files differ in content? – mstrap Oct 29 '14 at 19:37
  • The files are absolutely idential but, as you can see in the commit log on the screenshot, git considers them as 97% similar. "Does 'git log' display renames or additions/removals" - I'll check this soon. – Vlad Oct 30 '14 at 01:34
  • If Git considers them as renamed (when committing), but SmartGit later does not, that may indicate a problem. Is this a test repository? Can you please send it to smartgit@syntevo.com? – mstrap Oct 30 '14 at 08:43
  • No, it's not a test repo. It's a not pushed test commit. I checked, "git log protobuf-net/BclHelpers2.cs --follow" finds rename but SmartGit does not see it. To reproduce it just clone https://github.com/mgravell/protobuf-net.git, perform a rename of any file and commit. – Vlad Oct 30 '14 at 12:40
  • 1
    I've tried to rename `BclHelpers.cs` to `BclHelpers2.cs`, as you did. The problem with this file is that it's stored with CRLF in the repository before the rename and will be converted to LF after the rename. SmartGit performs no line ending canonicalization for its rename detection. To solve the problem, use `git config core.autocrlf false` on a fresh clone of the original repository, then perform the moves/renames. Now contents will be exactly identical and rename detection works for SmartGit as well. – mstrap Oct 30 '14 at 16:59