How can I move all git content one-level up in the folder hierarchy?

前端 未结 9 2258
北荒
北荒 2020-11-30 22:09

I have a git repository whose structure looks like:

+--repo.git
|
+----+bootstrap.py
+----+buildout.cfg
+----+.gitignore
+----+webapp
|
+---------+manage.py
         


        
相关标签:
9条回答
  • 2020-11-30 22:53

    Another variant of Sumeet's answer - in the repository directory above "webapp" execute following command:

    git mv webapp/* ./ -k
    

    -k - includes files which are yet not under version control, otherwise you get:

    fatal: not under version control, source=webapp/somefile, destination=somefile
    
    0 讨论(0)
  • 2020-11-30 22:54

    in windows you can do the below:

    While you are in the child folder

    for /f %f in ('dir /b') do git mv %f ../
    

    The result all objects in child folder will be in the parent folder

    Please note: some errors may raise when you have object in the child folder with name equals to the child folder

    0 讨论(0)
  • 2020-11-30 22:58

    If you are using PowerShell you can run this command from your project root and it will place the content of webapp there.

    Get-ChildItem .\webapp\ | ForEach-Object { git mv $_.FullName .\ }
    
    0 讨论(0)
提交回复
热议问题