Search code examples
gitbranchgit-clone

Clone a git repository into a existing non-empty directory


What is the best practice to clone a Git repository into an existing directory which already includes some other files and folders?

I have created 2 branches dev and master and locally working on dev branch. So I want to clone master branch in www folder which is the root of a website. Then at regular times I want to merge dev branch into master.

Now the problem is that I can't delete www director because it has essential contents. I also can't rename or move it.

Is there a way to fully clone the master branch into the root ofwww directory without renaming or deleting it's content?


Solution

  • Is there a way to fully clone the master branch into the root ofwww directory without renaming or deleting it's content?

    Clone the repo elsewhere (in master branch), then move the checked out files and the .git folder to the existing www/ folder.

    You might have to add the existing www/ files in your .gitignore.