0

I have a Repository (f.e. myproject). There are two directories (f.e. subtask1 and subtask2). Now I want to add a directory between them, so that the structure is: myproject -> task1 and in task1 are my two other directories. I wanted to change this in locally and then add it to git but by doing this, all files are lost in git. Later, I want to add another repository to myproject, so that all my projects are in one Repository. I already tried it, but my files are either lost or do not work anymore. I already tried different things, but nothing really works. Can someone maybe help me? Thank You!

San Dra
  • 3
  • 1
  • How are you doing this? Using an IDE interfaces or via command prompt? If prompt can you share some of the commands you're running? When you say it doesn't work, what exactly is not working? If it were me (and I am not a git expert) and I didn't need the changes history, I'd be wiping my local git folders, creating my finished repo structure locally now and adding git fresh... If you do want to go ahead though, there are various suggestions on the web for doing it such as https://stackoverflow.com/questions/18667308/move-file-and-directory-into-a-sub-directory-along-with-commit-history – Neve Dec 05 '20 at 09:05

1 Answers1

0

Before commiting, try staging the moved files using

git add .

git will automatically recognize that the files have just been renamed (in terms of their path).

Omri Shayo
  • 64
  • 8
  • This is my input on git bash: $ git status On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) renamed: subtask1/1.txt -> task1/subtask1/1.txt renamed: subtask2/2.txt -> task1/subtask2/2.txt – Omri Shayo Dec 05 '20 at 09:05