0

I am having some issue after I merged the code and the package/folder named are not showing as expected.

For example:- in master branch, someone has changed the below package name and pushed the code

com.example.mainDirectory => com.example.maindirectory 

Folder structure

src > java >main >com>example>mainDirectory  ==> src > java >main >com>example>maindirectory

Now in my local branch I am trying to merge the latest code from master, but the folder stanture for the adobe change is not reflecting, it's still showing src > java >main >com>example>mainDirectory instead of src > java >main >com>example>maindirectory

How I can resolve this issue ? so that it should sync with the master branch

newcoder
  • 464
  • 9
  • 23

2 Answers2

1

Here are 2 possible explanations for this:

  1. Both paths exist in the repo, differing only by case. You can check if this is the case (pun intended) using this command.
  2. Only the new path (with the desired casing) exists after the merge, but Git was unable to rewrite those paths, perhaps because they were locked at the time the merge was performed. In this case, make sure your working state is clean, delete the path with the wrong casing, and then git reset --hard HEAD to re-check out the new path with the desired casing.
TTT
  • 22,611
  • 8
  • 63
  • 69
  • I dont think both the point you mentioned is the case. 1.- everything is fine in remote branch, even when i did a git pull I also saw the folder name changed to all lowercase in my local master branch. 2. I did switch to my branch in local and did a git merge master which gave me no error/warning also it displayed the message "renamed src > java >main >com>example>mainDirectory ==> src > java >main >com>example>maindirectory" but the folder name was still showing mainDirectory though the java files inside them showing package name as "com.example.maindirectory" – newcoder Sep 14 '22 at 19:40
  • @Raj looks like you didn't try #2 yet then. After the merge, if you switch to `master` does the directory change to the desired casing? – TTT Sep 14 '22 at 19:43
  • @Raj also, when a *directory* is renamed, perhaps all of the files within it need to be repointed as well. Try running the command in #1 against the entire directory to see if anything on your branch is still pointing to the wrong casing. (Maybe you modified some of those files and the merge in `master` isn't touching them, so both directories actually *do* exist in your branch.) – TTT Sep 14 '22 at 19:45
  • I misunderstood the point 2, it seems that worked. Thanks – newcoder Sep 14 '22 at 19:52
0

I'm guessing this is on Windows. On Linux, case matters for the file system. On Windows it doesn't. There is a very easy two-step workaround:

  • Rename to src > java >main >com>example>maindirectory2
  • Rename to src > java >main >com>example>mainDirectory

The first rename tells both Git and Windows that the directory has renamed. The second rename does the same but gives you the result you want.

Rob Spoor
  • 6,186
  • 1
  • 19
  • 20
  • but this will show that I have made the changes, instead of the person who actually made this changes, I want to avoid that. Yes this in windows I guess that's why it's creating issue – newcoder Sep 14 '22 at 17:27
  • Then ask them to do the rename, properly this time. – Rob Spoor Sep 14 '22 at 17:31
  • rename is fine and properly pushed in master, but the only problem is when I am merging that into my local, though it's saying renamed src > java >main >com>example>mainDirectory ==> src > java >main >com>example>maindirectory, but the folder name in my local it's still showing as mainDirectory – newcoder Sep 14 '22 at 17:34