0

I want to a move folder and files in it to a new folder. Both folder name and file names have changed.

Dir1
  file11
  file12

 TO

Dir2
  file21
  file22

I also want to keep the history.

Can I do this in one commit? Or I need the following 2 steps?

git mv Dir1 Dir2
commit and push

git mv Dir2/file11 Dir2/file21
git mv Dir2/file11 Dir2/file22
commit and push
RedFox
  • 1,158
  • 2
  • 15
  • 28
  • @EncryptedWatermelon part of my question. Want to rename directory and also files in it. – RedFox Nov 20 '19 at 21:10
  • I am wondering why they made this as duplicate. This is not duplicate as this question asks how to rename a folder and also files in it. Duplicate question pointed only shows how to rename a folder. – RedFox Nov 20 '19 at 22:38

1 Answers1

2

Yes you can do this in only one commit with:

git mv Dir1 Dir2
git mv Dir2/file11 Dir2/file21
git mv Dir2/file11 Dir2/file22
commit and push

You can also do this in two commits and squash them using git rebase -i HEAD~3 if you prefer.

Tim
  • 2,052
  • 21
  • 30