I have a folder with files and sub folder in it and I have created a branch where I have been editing this folder and actually committed this (but not yet merged with the master).
However, I think I might have an issue if I do merge.
Assume my folder structure was like this:
Folder
- Sub-Folder A
- File A1
- File A2
- File A3
- Sub-Folder B
- File B1
- File B2
- File B3
And now I have edited to become:
Folder
- Sub-Folder A
- File A2 (Edited)
- File A3
- File A4
- Sub-Folder C
- File C1
- File C2
- File C3
I.E., File A1 deleted, File A2 edited, new File A4, Sub-Folder B and all contents deleted, a new Sub-Folder C.
I am concerned that the commit just seemed to have added the new and edited stuff and that the removed/deleted stuff will still be there when I merge.
Is this the case? How can I resolve if so?
I was thinking I should create a temp branch from master, git rm -f the folder, merge this back into master to remove the folder and then merge in the branch with the edits.
Is this a valid/workable approach?
You need to tell git about the files that you have removed. If you do a git status, it should list: A/A1, B/B1, B/B2, B/B3 as having been deleted. Having re-created your situation locally and then removed the files, git status gives:
If you do ‘git rm’ on each of A/A1, B/B1, B/B2 and B/B3 (despite the fact that the files no longer exists on disk) and commit those changes then it should all be fine.
Does that help? Let me know if I need to clarify.