I want to move all the content in a git repository one level up, and need this to apply for every branch I have. Literally, I have:
+--repo
+----+.git
+----+folder
+--------+ A
+--------+ B
And I want simply:
+--repo
+----+.git
+----+A
+----+B
This post How can I move all git content one-level up in the folder hierarchy? has an nice answer, suggesting to do:
git mv folder/* ./ -k
Now how do I do with all the branches? I can think of:
do the git mv
for master, then git rebase
for all, on master
do the git mv
for all branches?
Is there an advantage of one over the other? I saw also some answers based on git filter-branch --index-filter
(answer here) but don;t understand how to apply it to my case.
Thanks!
I would use the new git filter-repo
, which does replace the old git filter-branch
or BFG.
It comes with many usage examples, including path-based filtering, in order for you to move folder content to the top (assuming the top directory only includes folder)
cd /path/to/second/clone
git filter-repo --path-rename folder/:
By default, git filter-repo
applies to all branches.
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