I have a git repository whose structure looks like:
+--repo.git | +----+bootstrap.py +----+buildout.cfg +----+.gitignore +----+webapp | +---------+manage.py +---------+modules +---------+templates +---------+static +---------+... +---------+...
I would like to move the contents of the webapp
folder one level up. My resulting repo should look like:
+--repo.git | +----+bootstrap.py +----+buildout.cfg +----+.gitignore +----+manage.py +----+modules +----+templates +----+static +----+... +----+...
Can I do this by simply moving all the files of the webapp
directory one level up, deleting the empty webapp
directory and then committing the changes? Would this preserve the commit history of the files under the webapp
directory?
Although a very simple question for many of you, I'd like to be sure. The last thing I'd want is a git soup.
I tried moving the files but I lost the commit history as git doesn't really handle a move or a rename. I do know that even though it shows up as a new file in the logs, it is still possible to view the commit history for the file using some options in git log
.
From what I've read, the best way to accomplish this would be using git-filter
. I'm not very good with shell or git so could someone tell me what I'd need to execute to do the aforementioned.
To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory"). For example, to move one directory upwards (into the current folder's parent folder), you can just call: $ cd ..
To change the order of a file or folder, click the dots on to the left of the folder or file's name that you're interested in. Dragging while clicking will move the file or folder up and down. A gray outline will show you where the file will appear if you drop it at that point.
The right way to do this is:
git mv repo.git/webapp/* repo.git/. git rm repo.git/webapp git add * git commit -m "Folders moved out of webapp directory :-)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With