Difference between revisions of "Git Clone Command"
From InfoTechPedia
TomHutchison (talk | contribs) (new page) |
TomHutchison (talk | contribs) (category) |
||
Line 27: | Line 27: | ||
You will be prompted for a password, enter it and press return. If the path is correct and the <code>/.git</code> directory is found in the parent directory ( the example above, <code>/newProject</code> ) then the download and cloning of the git repo will complete. Remember is must be the absolute path to the file. | You will be prompted for a password, enter it and press return. If the path is correct and the <code>/.git</code> directory is found in the parent directory ( the example above, <code>/newProject</code> ) then the download and cloning of the git repo will complete. Remember is must be the absolute path to the file. | ||
+ | |||
+ | [[Category:Git Commands]] |
Latest revision as of 10:37, 1 March 2018
There are two methods to download an existing project and create a local work copy. Depending on the host of the git repository, this will change the syntax.
Clone from GitHub
Either make the directory and cd
to it and use git clone ...
which will add an additional subdirectory ( which may not be desirable ) inside the newly made directory.
gitRepoDirectory | cd coolProject -- coolProject | git clone https://github.com/username/coolProject.git -- coolProject (new directory created with all the cloned files and directories) Better to specify a working directory for better organization and create the directory. gitRepoDirectory | git clone https://github.com/username/coolProject.git coolProject -- coolProject (which will have all the cloned files and directories)
The second method is more desirable otherwise you may end up with lots of directories, with only a git project directory in each one. This allows you to have a master git repo directory and then have all projects in that directory.
Cloning from Remote Server
Very similar to a GitHub repo clone only you will need to use ssh to shell into the server over port 22 or whatever the ssh port for the server is. You can use a similar directory structure, mkdir directory
and cd
to create your structure. Then issue the command to clone with shh. Of course the remote server needs access with ssh.
git clone ssh://[email protected]:22/path/to/repository/newProject/.git newProject
You will be prompted for a password, enter it and press return. If the path is correct and the /.git
directory is found in the parent directory ( the example above, /newProject
) then the download and cloning of the git repo will complete. Remember is must be the absolute path to the file.