1

I created too many folder layers, so now I need move the project up by one layer. Here is what I have for folder structure.

OMDM/OKE/OKEPortal

I would like the new structure to look like this while keeping the Git record history.

OMDM/OKEPortal

I have used the Git commands below, but it ends up changing the folder name instead of moving it.

git mv OKEPortal OKE
git add OKEPortal

Somehow, it always ends up changing the folder name.

Update:

While I'm in OMDM directory, i run the below commands

mv OKE/OKEPortal OKEPortal
rm -r OKE
git add OKEPortal

I think before I didn't get the result that i wanted because I didn't put the folder path correctly when executing "git mv OKEPortal OKE" thus it always changed the folder name from OKEPortal to OKE. It was my mistake. The source and destination directory should not be the same else it will rename the folder instead of move.

Phil
  • 323
  • 2
  • 12
  • Did you try simply moving things as you'd like it to be with your OS (not using Git commands) and using git add ? – Gimly Aug 24 '20 at 21:15
  • I tried manually copy the folder and moved to "OKE" folder but when I started Git Bash, it showed Deletion and Adding instead. I was hoping "move to" or something so other users know that is not new project. – Phil Aug 24 '20 at 21:24
  • Does this answer your question? [How to move a git repository into another directory and make that directory a git repository?](https://stackoverflow.com/questions/19097259/how-to-move-a-git-repository-into-another-directory-and-make-that-directory-a-gi) – SwissCodeMen Aug 24 '20 at 21:24
  • I looked at that post and looked at the second option for the "move" instead of "copy". The move is like I did but it didn't move. – Phil Aug 24 '20 at 21:36
  • @Phil git status always shows "add / deletion" when moving a file. But doing `git add .` should make git understand that they were moved and should correctly show "moved". – Gimly Aug 25 '20 at 06:42

1 Answers1

0

If the .git folder, which is at the root of all projects, is under

OMDM/OKE/OKEPortal/.git

then you can simple move the folder OKEPortal using the mouse or the command mv. Don't Forget to delete the folder OKE.

Ito Pakito
  • 98
  • 1
  • 9
  • ohh the ".git" is in top layer called Automation. So it looks like this Automation/OMDM/OKE/OKEPortal so ".git" is in Automation folder – Phil Aug 24 '20 at 21:22
  • I think git is smart enough to detect that you move the files if you perform a `git add`. – Ito Pakito Aug 24 '20 at 21:26
  • when i execute the move command, do I need to navigate to OKEPortal folder? because if I don't do that, it says the folder does not exist – Phil Aug 24 '20 at 21:37