How to duplicate directory in git, tracking new files?
Solution 1:
If you don't care about the history, you could just copy the directory and then git add
it:
$ cp -R old_dir new_dir
$ git add new_dir
$ git commit -m "first revision of new_dir's copied files"
Solution 2:
You can go to your intended directory and clone your git project again.
$ cd "new_directory"
$ git clone "your_project_git_address"
Solution 3:
If you want to have two separately same projects in git, follow this command lines:
$ mkdir "duplicated_project"
$ cd "your_project_path"
$ sudo cp -R * "duplicated_project_path/"
Then you must add/define this duplicated project on git, so you can follow:
Adding an existing project to GitHub using the command line tutorial:
GitHub Reference
Or
You can duplicate your project in web ui:
i.e. if you are using from the Gitlab you can duplicate/export your project, such as bellow instruction:
- In the left side in Setting tab --> select General --> expand Export project --> click on export.
Then follow this command line:
$ git clone "duplicated/exported_project"
[NOTE]:
In these mentioned approaches have not interfered commits.
Solution 4:
Basically your question is how to separate versioned files from unversioned.
This answer assumes you set up a server where you push your repo for backup, etc.
Push your branch dev to the server origin: git push origin dev
Note, only the versioned files go to the server.
Look at the server with a web browser and find the folder you want to copy.
Right click on the folder you want to copy and select download as zip.
In windows make a folder new_project. Copy folder from the zip file to new_project.
Now you copied all your versioned files to new_project.
Add the new project to git: git add new_project.
This will add the folder new_project, all files and sub folders to git in one command.
Enjoy your new project.