0

I have set of files in my repository with out any structure. I would like to create relevant folders to organise files which are already exists my repo.

Simply : I need to create folder, and move some of exiting files to current folder.

How can I do this?

Thanks

Kid
  • 169
  • 1
  • 19

2 Answers2

0

Just create folders you want, move files you want and run below command to add changes

git add -A

And then commit your changes

git commit -m 'Description of changes'

Note that git do not store data about folders, it store data about other files

You can find detailed description of above commands here:

https://git-scm.com/docs/git-commit

https://git-scm.com/docs/git-add

pato
  • 868
  • 5
  • 10
  • Thanks for the answer. Do git see this as a newly added files? or existing files with a modified path? Because I don’t want to loose any previous history of that file. – Kid Nov 25 '16 at 14:55
  • Git will see this file as renamed and will store it history. You can see history before renaming with --follow flag eg: git log --follow file_path – pato Nov 25 '16 at 14:58
  • @pato But this option may not always work well, or at all. – Tim Biegeleisen Nov 25 '16 at 15:04
  • @TimBiegeleisen yeap, but I've never heard about other way. If you only move file and do not change it's content it should work properly. So commit changes, move files and do not introduce other changes, commit again. – pato Nov 25 '16 at 15:12
0

All you need to do is create a new folder in your file system, and then move the relevant files into this folder.

After you have done this, when you type git status you will see the files you have moved listed in the change set.

Specifically, for eached moved file you see an entry for having deleted the file in its original location and having added it in the new folder.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thanks for the response. Does it mean I cant keep the history of the file and cant revert to previous version of that file? – Kid Nov 25 '16 at 15:01
  • @Kid It is not easy to maintain history across a move/rename, q.v. here: http://stackoverflow.com/questions/2314652/is-it-possible-to-move-rename-files-in-git-and-maintain-their-history – Tim Biegeleisen Nov 25 '16 at 15:03