I have a working copy of the project, without any source control meta data. Now, I'd like to do the equivalent of git-clone into this folder, and keep my local changes.
git-clone doesn't allow me to clone into an existing folder. What is the best practice here?
However, you can only clone into an existing directory only when it is empty. Otherwise, git will complain that the destination path already exists and is not an empty directory. That's all about cloning a Git repository into a specific folder.
To clone git repository into a specific folder, you can use -C <path> parameter, e.g. Although it'll still create a whatever folder on top of it, so to clone the content of the repository into current directory, use the following syntax: cd /httpdocs git clone [email protected]:whatever .
When you clone a repository, you copy the repository from GitHub.com to your local machine. Cloning a repository pulls down a full copy of all the repository data that GitHub.com has at that point in time, including all versions of every file and folder for the project.
The correct command is rsync -azv --exclude '. git' source/ destination/ , which copies contents of source folder to destination folder.
This can be done by cloning to a new directory, then moving the .git
directory into your existing directory.
If your existing directory is named "code".
git clone https://myrepo.com/git.git temp mv temp/.git code/.git rm -rf temp
This can also be done without doing a checkout during the clone command; more information can be found here.
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