Github When I Clone Again

Git clone illustration

Git Clone

The git clone command is used to create a copy of a specific repository or branch within a repository.

Git is a distributed version control system. Maximize the advantages of a total repository on your own machine past cloning.

What Does git clone Do?

git clone https://github.com/github/training-kit.git

When you clone a repository, you don't go one file, like you may in other centralized version command systems. By cloning with Git, you become the unabridged repository - all files, all branches, and all commits.

Cloning a repository is typically only done one time, at the beginning of your interaction with a project. Once a repository already exists on a remote, like on GitHub, so you would clone that repository so yous could collaborate with it locally. In one case you have cloned a repository, you won't need to clone it again to do regular development.

The ability to work with the entire repository ways that all developers can work more freely. Without being express past which files you tin can work on, you can work on a feature branch to brand changes safely. Then, you can:

  • later employ git push to share your branch with the remote repository
  • open a pull request to compare the changes with your collaborators
  • test and deploy every bit needed from the branch
  • merge into the main branch.

How to Use git clone

Common usages and options for git clone

  • git clone [url]: Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits.
  • git clone --mirror: Clone a repository merely without the power to edit any of the files. This includes the refs, or branches. You may want to employ this if you lot are trying to create a secondary copy of a repository on a carve up remote and y'all want to lucifer all of the branches. This may occur during configuration using a new remote for your Git hosting, or when using Git during automated testing.
  • git clone --single-branch: Clone only a single branch
  • git clone --sparse: Instead of populating the working directory with all of the files in the current commit recursively, but populate the files present in the root directory. This could assist with operation when cloning large repositories with many directories and sub-directories.
  • `git clone --recurse-submodules[=<pathspec]: After the clone is created, initialize and clone submodules inside based on the provided pathspec. This may be a good choice if you are cloning a repository that you know to have submodules, and y'all will exist working with those submodules every bit dependencies in your local development.

You can see all of the many options with git clone in git-scm'southward documentation.

Examples of git clone

git clone [url]

The most mutual usage of cloning is to simply clone a repository. This is simply done one time, when you begin working on a project, and would follow the syntax of git clone [url].

git clone A Branch

git clone --single-branch: By default, git clone will create remote tracking branches for all of the branches currently nowadays in the remote which is being cloned. The only local branch that is created is the default branch.

But, maybe for some reason you would similar to only go a remote tracking co-operative for one specific co-operative, or clone i branch which isn't the default co-operative. Both of these things happen when you use --single-branch with git clone.

This volition create a clone that only has commits included in the current line of history. This means no other branches volition be cloned. You tin can specify a certain co-operative to clone, only the default branch, usually main, volition be selected by default.

To clone one specific branch, employ:

git clone [url] --branch [branch] --single-branch

Cloning merely 1 branch does non add any benefits unless the repository is very big and contains binary files that deadening down the operation of the repository. The recommended solution is to optimize the operation of the repository before relying on single branch cloning strategies.

git clone With SSH

Depending on how you cosign with the remote server, you may choose to clone using SSH.

If yous choose to clone with SSH, you would utilise a specific SSH path for the repository instead of a URL. Typically, developers are authenticated with SSH from the auto level. This means that you lot would probably clone with HTTPS or with SSH - non a mix of both for your repositories.

Related Terms

  • git branch: This shows the existing branches in your local repository. You tin also employ git branch [banch-name] to create a co-operative from your current location, or git branch --all to see all branches, both the local ones on your machine, and the remote tracking branches stored from the final git pull or git fetch from the remote.
  • git pull: Updates your current local working co-operative with all new commits from the corresponding remote co-operative on GitHub. git pull is a combination of git fetch and git merge.
  • git push: Uploads all local branch commits to the remote.
  • git remote -5: Evidence the associated remote repositories and their stored name, like origin.

Contribute to this article on GitHub.

Get started with git and GitHub

Review code, manage projects, and build software alongside 40 million developers.

Sign upwardly for GitHub Sign in

trejocourester.blogspot.com

Source: https://github.com/git-guides/git-clone

0 Response to "Github When I Clone Again"

Enregistrer un commentaire

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel