in Technology by
How can we clone a Git repository into a specific folder?

1 Answer

0 votes
by

Option A:

git clone [email protected]:whatever folder-name

Ergo, for right here use:

git clone [email protected]:whatever .

Option B:

Move the .git folder, too. Note that the .git folder is hidden in most graphical file explorers, so be sure to show hidden files.

mv /where/it/is/right/now/* /where/I/want/it/
mv /where/it/is/right/now/.* /where/I/want/it/

The first line grabs all normal files, the second line grabs dot-files. It is also possibe to do it in one line by enabling dotglob (i.e. shopt -s dotglob) but that is probably a bad solution if you are asking the question this answer answers.

Better yet:

Keep your working copy somewhere else, and create a symbolic link. Like this:

ln -s /where/it/is/right/now /the/path/I/want/to/use

For your case this would be something like:

ln -sfn /opt/projectA/prod/public /httpdocs/public

Which easily could be changed to test if you wanted it, i.e.:

ln -sfn /opt/projectA/test/public /httpdocs/public

without moving files around. Added -fn in case someone is copying these lines (-f is force, -n avoid some often unwanted interactions with already and non-existing links).

If you just want it to work, use Option A, if someone else is going to look at what you have done, use Option C.

Related questions

0 votes
    I have a Visual Studio online Team Project with a repository. I have been using this with VS 2013 for a ... and doing clone again? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    How to clone all remote branches in Git?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    I have a Git repository which contains a number of subdirectories. Now I have found that one of the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Can we create a clone of a singleton object?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is the use of git clone command?...
asked Nov 4, 2020 in Technology by JackTerrance
0 votes
    What is the difference between ‘git remote’ and ‘git clone’?...
asked Nov 2, 2020 in Technology by JackTerrance
0 votes
    Microsoft now has support for Git repositories on their Team Foundation Service. I have an account on Team ... to TFService. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I pulled a project from GitHub a few days ago. I've since discovered that there are several forks on GitHub, ... those forks I pulled? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Why there is a need to move the existing directory into a new repository? How this can be done in SVN?...
asked Feb 18, 2021 in Technology by JackTerrance
0 votes
    On adding a subproject using git submodule add, how many files will be added in the main repository? (1)4 (2)1 (3)2 (4)3...
asked Jun 1, 2021 in Technology by JackTerrance
0 votes
    How to find and restore a deleted file in a Git repository?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    Explain How to change the URI (URL) for a remote Git repository?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    How to determine the URL that a local Git repository was originally cloned from?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    How to add an empty directory to a Git repository?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    How to push a new local branch to a remote Git repository and track it too?...
asked Jan 7, 2021 in Technology by JackTerrance
...