Introduction
If you simply issue a git clone command, the git cloning process will create a new directory for the repository.
In this tutorial, we will show you how to clone a git repository into a specific folder.
Clone a Git Repository Into a Specific Folder
General-purpose of git cloning is to create a local copy of the remote repository. However, cloning without specifying the exact directory will create a new one.
This may lead to a lot of clutter residing on your server.
That is why specifying the directory to which you want to clone is an important thing.
Syntax of git clone
git clone [repo URL that want to clone] [/the/path/I/want/to/use]
For Example
We can do that in three options:
Option A:
git clone https://[email protected]:whatever.git /home/unixcop/project
The command that is shown in the example above will clone whatever.git repository into a project directory that resides within the unixcop user.
For right here use:
git clone [email protected]:whatever.git
Option B:
Move the .git folder, too.
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.
Option C:
Keep your working copy somewhere else, and create a symbolic link.
ln -sfn /where/it/is/right/now /the/path/I/want/to/use
Without moving files around.
- -fn in case someone is copying these lines (-f is force, -n avoid some often unwanted interactions with already and non-existing links).
Conclusion
You learned how to clone a git repository into a new directory.
You also may search on how to create Git tags, So kindly visit this article Create A Git Tags.