Difference between revisions of "Git/clone"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Git
Jump to navigation Jump to search
(Created page with "'''Action''': clones a repository into a new directory After cloning, a plain git {{l/same|fetch}} without arguments will update all the remote-tracking branches, and a git {...")
 
(more usage information)
 
Line 1: Line 1:
'''Action''': clones a repository into a new directory
+
[[category:git/commands|clone]]
 +
* '''Action''': clones a repository into a new directory
 +
* '''Format''': <code>git clone {{arg|URL.git}}</code>
  
After cloning, a plain git {{l/same|fetch}} without arguments will update all the remote-tracking branches, and a git {{l/same|pull}} without arguments will in addition merge the remote master branch into the current master branch, if any, unless the "--single-branch" option is used.
+
A "clone" is a ''new'' copy of an existing project {{l/same|repository}}.
 +
 
 +
The files will be placed in a ''subfolder'' of the current folder, and will refuse to put anything into an existing folder &ndash; so if you already have a project folder set up, you'll need to delete it (or rename it temporarily if you need to merge the contents).
 +
 
 +
I'm not sure what this means, but it seems relevant &rarr; ''After cloning, a plain git {{l/same|fetch}} without arguments will update all the remote-tracking branches, and a git {{l/same|pull}} without arguments will in addition merge the remote master branch into the current master branch, if any, unless the "--single-branch" option is used.'' (Note that these would need to be executed ''inside'' the project folder. Doing a "git pull" right after "git clone ..." resulted only in the message "Already up-to-date." when I tried it just now.)
 
==Question==
 
==Question==
What happens if you clone a repository into the same directory you cloned it into earlier?
+
* '''Q:''' What happens if you clone a repository into the same directory you cloned it into earlier?
 +
** '''A:''' You can't; the clone command will respond "fatal: destination path '{{arg|project name}}' already exists and is not an empty directory.".
 
==Links==
 
==Links==
 
===Documentation===
 
===Documentation===
 
* [https://www.kernel.org/pub/software/scm/git/docs/git-clone.html manpage @ kernel.org]
 
* [https://www.kernel.org/pub/software/scm/git/docs/git-clone.html manpage @ kernel.org]

Latest revision as of 21:43, 9 March 2015

  • Action: clones a repository into a new directory
  • Format: git clone <URL.git>

A "clone" is a new copy of an existing project repository.

The files will be placed in a subfolder of the current folder, and will refuse to put anything into an existing folder – so if you already have a project folder set up, you'll need to delete it (or rename it temporarily if you need to merge the contents).

I'm not sure what this means, but it seems relevant → After cloning, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any, unless the "--single-branch" option is used. (Note that these would need to be executed inside the project folder. Doing a "git pull" right after "git clone ..." resulted only in the message "Already up-to-date." when I tried it just now.)

Question

  • Q: What happens if you clone a repository into the same directory you cloned it into earlier?
    • A: You can't; the clone command will respond "fatal: destination path '<project name>' already exists and is not an empty directory.".

Links

Documentation