1

I am trying to restructure my code and did mv to move files to directories.

This lead to git having duplicate files, both in the original directory and in the moved directory.

How do I ensure that the files in the "original" directory are deleted on the remote but kept in the moved directory?

tandem
  • 2,040
  • 4
  • 25
  • 52
  • Was your repo clean when you started moving files around ? If yes, a simple `git add .` should do the right thing. – LeGEC Jan 15 '21 at 09:21
  • 1
    Does `git add .` or `git add -A` not solve this? It automatically resolves that files have been moved for me. – Amit Singh Jan 15 '21 at 09:21

2 Answers2

0

You can simply add your new file and remove the old file from the repository.

git add newFolder/newFile.html
git rm oldFolder/oldFile.html

EDIT:

Regarding this post it makes no difference whether you run git mv or mv. Git should recognise that. So it should be possible to push the movements of the files with:

git add -A
flaxel
  • 4,173
  • 4
  • 17
  • 30
0

Assuming that you have a clean work tree before you did the file movement (this can be checked using git status before moving files), simply running

git add -A

should do it for you.

Amit Singh
  • 2,875
  • 14
  • 30