简体   繁体   中英

Git change the repo path of a subfolder

I've got a git structure like the following:

/web_app
-- /static
-- /templates
-- app.py

Having this, when i push to my repo, its pushed following exactly that folder structure, but what I want in the repo is this structure:

/web_app
--  /web
    -- /static
    -- /template
-- app.py

So what I want to do is somehow, from my folder in my pc push the folders /static and /templates into /web/ in repo, and when pulling or clonning, keep the original folder structure.

I've been searching trough docs for submodules and subtrees but either I didn't understand well how they work or they don't satisfy my necessities.

So, Is there any way to accomplish this?

Thanks in advance!

My first recommendation is to download the git cheat sheet and keep it handy on your desktop.

The command to accomplish what you want to do is git mv <source> <destination>. in the shell. The documentation for the command states that it will work on directories.

In your case, this means, from the /web_app directory, you should make your "web" directory:

md web

Then you should move your directories

git mv ./static ./web/static
git mv ./template ./web/template

What I finnally did was the following:

I created a new Repo, and with git submodule modularized /web.

It solves my problem, but for real problem I posted, check MK Hunter option

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM