0

I have repo like this

/repo
  |__/AAA 
  |__/BBB 
  |__/src 
       |___CCC

I am trying to move AAA and BBB to CCC using git mv command. I do git status and it shows there are no add/deletes, only renames. After this I do git commit and git push.

When I look up contributors section on Github, my additions/removal count has increased by big number.

This is unfair for other developers as I haven't changed anything, just moved files.

Is there way to avoid this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Amit
  • 797
  • 9
  • 32
  • 3
    No, Git doesn't track moves, it only infers them after the fact. – user229044 Aug 02 '19 at 01:48
  • 2
    One easy solution would be to just have the team lead/manager do such moving operations. He would still be credited with a big contribution, but then again the manager would likely be taking credit for everyone's work anyway :-) – Tim Biegeleisen Aug 02 '19 at 01:48
  • @meagar Git can _sometimes_ track moves, it uses fuzzy matching. It may or may not be able to do it, so best practice is to avoid moving things in Git. – Tim Biegeleisen Aug 02 '19 at 01:48
  • Possible duplicate of [How to make git mark a deleted and a new file as a file move?](https://stackoverflow.com/questions/433111/how-to-make-git-mark-a-deleted-and-a-new-file-as-a-file-move) – matt Aug 02 '19 at 01:53
  • this is not duplicate q – Amit Aug 02 '19 at 02:28
  • @amit How is it not a duplicate? I don't necessarily disagree, just want to hear your opinion. – wjandrea Aug 02 '19 at 03:34
  • 4
    Note that GitHub's counts are *approximations*. You can't get GitHub to do any better unless you go work for GitHub, probably. :-) – torek Aug 02 '19 at 03:59
  • @matt I don't agree with the duplicate flag because that question is about making **Git** recognize the moves, while this question is about making **GitHub** count them as such, which apparently doesn't follow from the former. – joanis Aug 02 '19 at 13:01
  • 1
    @TimBiegeleisen That's what I meant when I said git can *infer* moves. Git doesn't *track* moves, each Git commit is a snapshot of the file and directory hierarchy. Moves happen *between* commits, and are not tracked, but Git can sometimes make a good guess that when a commit removes one file, and introduces another, and the content is identical, that this was actually a move. "Tracking" has a pretty well defined meaning in Git, objects that are committed into Git are "tracked". Git has no object that tracks a move or a rename, it has no facility for actually **tracking** that. – user229044 Aug 02 '19 at 14:08
  • 1
    (Pro tip: please do not add any notes to say this is not a duplicate question. That would mean this is not a duplicate of any question at all on Stack Overflow, which is a pretty bold claim, given the millions of questions you would have to have checked. You can respond to specific claims, e.g. "it is not a duplicate of because of ". Try to avoid suggesting that your audience should "read properly" or "read more carefully", as that is generally regarded as implying stupidity on the part of the reader, and is thus potentially insulting). – halfer Aug 02 '19 at 19:54

0 Answers0