- Клонирование репозитория с GitHub через Git на Windows
- Cloning a repository
- In this article
- About cloning a repository
- Cloning a repository using the command line
- Cloning a repository to GitHub Desktop
- Cloning an empty repository
- Troubleshooting cloning errors
- Further reading
- Help us make these docs great!
- Cloning and forking repositories from GitHub Desktop
- In this article
- About local repositories
- Cloning a repository
- Forking a repository
- Managing fork behavior
- Cloning a repository from GitHub to GitHub Desktop
- Как сделать копию репозитория GitHub на компьютер
Клонирование репозитория с GitHub через Git на Windows
Репозиторий — это место, где хранятся некие данные (файлы), можно сказать, что это просто директория или же папка.
Для того, чтобы получить файлы с какого-либо репозитория или элементарно по-быстрому связать папку на своём компьютере с удалённым репозиторием.
Удалённый репозиторий — это место в неком облачном хранилище, к которой Вы имеете доступ, в котором хранятся некие данные (файлы).
В качестве примера будем клонировать репозиторий с GitHub специально подготовленный для данного урока. Файл, находящийся в рассматриваемом репозитории, не несёт ничего особо важного. Там хранится текстовый файл с текстом внутри.
Примечание: на операционной системе Windows (в некоторых версиях) периодически возникают проблемы с «правами доступа». Чтобы не править настройки (каждый случай, можно сказать, индивидуален) будем использовать вариант, который работает во многих случаях.
Примечание: если Вы подключены к интернету с помощью прокси — могут возникнуть проблемы.
- Перейдите в папку «Мои документы»;
- Создайте папку с названием «Git». Имя можете сделать своё (лучше используйте латиницу), в примере будет рассматриваться имя папки «Git»;
- Кликните правой кнопкой мыши в папке «Git» и выберите «Git Bash Here». Откроется консоль;
- Введите команду
Cloning a repository
When you create a repository on GitHub, it exists as a remote repository. You can clone your repository to create a local copy on your computer and sync between the two locations.
In this article
About cloning a repository
You can clone a repository from GitHub to your local computer to make it easier to fix merge conflicts, add or remove files, and push larger commits. When you clone a repository, you copy the repository from GitHub to your local machine.
Cloning a repository pulls down a full copy of all the repository data that GitHub has at that point in time, including all versions of every file and folder for the project. You can push your changes to the remote repository on GitHub, or pull other people’s changes from GitHub. For more information, see «Using Git».
You can clone your existing repository or clone another person’s existing repository to contribute to a project.
Tip: You can also clone a repository using the GitHub CLI. For more information, see » gh repo clone » in the GitHub CLI documentation.
Cloning a repository using the command line
On GitHub, navigate to the main page of the repository.
Above the list of files, click
Code.
To clone the repository using HTTPS, under «Clone with HTTPS», click
. To clone the repository using an SSH key, including a certificate issued by your organization’s SSH certificate authority, click Use SSH, then click
. To clone a repository using GitHub CLI, click Use GitHub CLI, then click
Open Terminal Terminal Git Bash .
Change the current working directory to the location where you want the cloned directory.
Type git clone , and then paste the URL you copied earlier.
Press Enter to create your local clone.
Cloning a repository to GitHub Desktop
On GitHub, navigate to the main page of the repository.
Above the list of files, click
Code.
Open with GitHub Desktop to clone and open the repository with GitHub Desktop.
Follow the prompts in GitHub Desktop to complete the clone.
Cloning an empty repository
An empty repository contains no files. It’s often made if you don’t initialize the repository with a README when creating it.
On GitHub, navigate to the main page of the repository.
To clone your repository using the command line using HTTPS, under «Quick setup», click
. To clone the repository using an SSH key, including a certificate issued by your organization’s SSH certificate authority, click SSH, then click
Alternatively, to clone your repository in Desktop, click
Set up in Desktop and follow the prompts to complete the clone.
Open Terminal Terminal Git Bash .
Change the current working directory to the location where you want the cloned directory.
Type git clone , and then paste the URL you copied earlier.
Press Enter to create your local clone.
Troubleshooting cloning errors
When cloning a repository it’s possible that you might encounter some errors.
If you’re unable to clone a repository, check that:
- You can connect using HTTPS. For more information, see «HTTPS cloning errors.»
- You have permission to access the repository you want to clone. For more information, see «Error: Repository not found.»
- The default branch you want to clone still exists. For more information, see have permission to access the repository you want to clone. For more information, see «Error: Remote HEAD refers to nonexistent ref, unable to checkout.»
Further reading
Help us make these docs great!
All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.
Cloning and forking repositories from GitHub Desktop
You can use GitHub Desktop to clone and fork repositories that exist on GitHub.
In this article
About local repositories
Repositories on GitHub are remote repositories. You can clone or fork a repository with GitHub Desktop to create a local repository on your computer.
You can create a local copy of any repository on GitHub that you have access to by cloning the repository. If you own a repository or have write permissions, you can sync between the local and remote locations. For more information, see «Syncing your branch.»
When you clone a repository, any changes you push to GitHub will affect the original repository. To make changes without affecting the original project, you can create a separate copy by forking the repository. You can create a pull request to propose that maintainers incorporate the changes in your fork into the original upstream repository. For more information, see «About forks.»
When you try to use GitHub Desktop to clone a repository that you do not have write access to, GitHub Desktop will prompt you to create a fork automatically. You can choose to use your fork to contribute to the original upstream repository or to work independently on your own project. Any existing forks default to contributing changes to their upstream repositories. You can modify this choice at any time. For more information, see «Managing fork behavior».
You can also clone a repository directly from GitHub or GitHub Enterprise. For more information, see «Cloning a repository from GitHub to GitHub Desktop».
Cloning a repository
In the File menu, click Clone Repository.
Click the tab that corresponds to the location of the repository you want to clone. You can also click URL to manually enter the repository location.
Choose the repository you want to clone from the list.
Click Choose. and navigate to a local path where you want to clone the repository.
Click Clone.
Forking a repository
If you clone a repository that you do not have write access to, GitHub Desktop will create a fork. After creating or cloning a fork, GitHub Desktop will ask how you are planning to use the fork.
In the File menu, click Clone Repository.
Click the tab that corresponds to the location of the repository you want to clone. You can also click URL to manually enter the repository location.
Choose the repository you want to clone from the list.
Click Choose. and navigate to a local path where you want to clone the repository.
Click Clone.
If you plan to use this fork for contributing to the original upstream repository, click To contribute to the parent project.
If you plan to use this fork for a project not connected to the upstream, click For my own purposes.
Click Continue.
Managing fork behavior
You can change how a fork behaves with the upstream repository in GitHub Desktop.
Open the Repository menu, then click Repository settings. .
Click Fork behavior, then select how you want to use the fork.
Cloning a repository from GitHub to GitHub Desktop
You can use GitHub to clone remote repositories to GitHub Desktop.
Tip: You also can use GitHub Desktop to clone repositories that exist on GitHub. For more information, see «Cloning a repository from GitHub Desktop.»
Sign in to GitHub and GitHub Desktop before you start to clone.
On GitHub, navigate to the main page of the repository.
Above the list of files, click
Code.
Open with GitHub Desktop to clone and open the repository with GitHub Desktop.
Click Choose. and, using the Finder window, navigate to a local path where you want to clone the repository.
Note: If the repository is configured to use LFS, you will be prompted to initialize Git LFS.
Click Clone.
Sign in to GitHub and GitHub Desktop before you start to clone.
On GitHub, navigate to the main page of the repository.
Above the list of files, click
Code.
Open with GitHub Desktop to clone and open the repository with GitHub Desktop.
Click Choose. and, using Windows Explorer, navigate to a local path where you want to clone the repository.
Note: If the repository is configured to use LFS, you will be prompted to initialize Git LFS.
Как сделать копию репозитория GitHub на компьютер
Инструкция как быстро и просто сделать копию репозитория GitHub к себе на компьютер при помощи редактора Visual Studio Code. Задача буквально на три клика.
Давненько не клонировал репозитории GitHub из-за чего не сразу вспомнил как это делается. Это при том что в редакторе VSCode весь процесс занимает буквально два-три клика мышкой.
Если коротко и по делу, то весь процесс таков:
- Берём ссылку на репозиторий GitHub
- Нажимаем клавишу F1 и вводим команду Git: Clone
- В поле ввода вставляем ссылку на репозиторий
- Выбираем место куда сохранять
Теперь всё то же только уже со скриншотами.
Открываем редактор VSCode и нажимаем на клавиатуре клавишу F1 . В появившейся командной строке редактора вводим команду Git: Clone
После запуска команды Git: Clone появляется поле ввода где просят указать ссылку на клонируемый репозиторий:
В это поле нужно вставить ссылку на репозиторий GitHub который нужно скопировать на компьютер. Ссылку можно взять на странице самого репозитория. Для этого нажимаем кнопку Code и в появившемся окне нажимаем кнопку скопировать url
После того как вставите ссылку на репозиторий в поле ввода — нажимаете клавишу Enter и вам будет предложено указать место на компьютере куда сохранять репозиторий.
После того как укажите место для сохранения, система начнёт скачивать репозиторий. Когда скачивание завершится, в правом нижнем углу редактора появится такое сообщение:
Вы можете закрыть сообщение или открыть репозиторий одним из предложенных способов.