0

I am having an issue while renaming a package and then pushing it to git remote repo. I used Intellij > Refactor > rename to rename the package, in local Git status is showing as renamed file but in github when raising a pull request it is showing that old package as deleted and new package as added.

How to resolve this and tell git to consider them as renamed ?

Example: com.test.examplePackage ===> renamed to com.test.examplepackage (we have almost 500 files in this packge)

Now github is showing

com/test/examplePackage/Xyz.java -- deleted
com/test/examplepackage/Xyz.java -- added

Instead of com/test/examplePackage/Xyz.java ===> renamed to com/test/examplepackage/Xyz.java

newcoder
  • 464
  • 9
  • 23
  • Renamed or deleted-and-added makes no difference at all to Git itself. The choice of presentation (as either renamed, or as deleted-and-added) is up to the program or user invoking `git diff`, except that, as [JockX answered](https://stackoverflow.com/a/73575278/1256452), there's also a minimum similarity required (you can ask for a different minimum than the default, when you run `git diff`, but if you're using GItHub, GitHub do not let you do that). – torek Sep 02 '22 at 08:10

1 Answers1

1

Similar question has been already answered here: How to make git mark a deleted and a new file as a file move?

In short, Git will consider the file/directory deleted if the content was modified beyond certain treshold. For this reason you may want to do separate commits for just renaming, and separate for changing file content inside.

Another factor that may be relevant in this case, is that when merging using squash your separate commits are bulked into one, which may explain the different behaviour locally and in github - commit squashing may be turned on by default in your repo.

JockX
  • 1,928
  • 1
  • 16
  • 30
  • my doubt is in local all the files were showing renamed (git/commit status) when i pushed the code to remote there it's showing as added/deleted, is it a expected behavior ? – newcoder Sep 01 '22 at 21:02