How to clone github repository ubuntu
How to clone github repository ubuntu
Search Results
No Results
Filters
How to Install Git and Clone a GitHub Repository
GitHub is a website that allows collaboration between developers using the Git version control system. With Git and GitHub, programmers from across the world can share ideas and code in an organized and up-to-date process.
Install and Configure Git
The directions below are for Debian or Ubuntu. For installation on Mac, Windows, or other Linux distributions, find instructions in the Git Source Control Management guide. While that guide focuses on Git, this guide focuses more on Git with GitHub.
Configure the username, replace First Last :
Configure the email, replace example@example.com :
Now that Git has been installed, refer to the image below for help with using Git and GitHub together.
Clone a GitHub Test Repository
A repository, or repo, is a Git project. For tutorial purposes, there is a test repository setup on GitHub, which is listed below.
Copy the βHTTPS clone URLβ link using the clipboard icon at the bottom right of the pageβs side-bar, pictured below.
Change directories to the new
To ensure that your master branch is up-to-date, use the pull command:
Create a GitHub Account and Fork the Test Repo
To share new files or file revisions, youβll need a GitHub account and a project fork. A fork is a copy of a repo held on your GitHub account.
Create a username on GitHub. At the βWelcome to GitHubβ page, select the green, βFinish sign upβ button at the bottom.
Select your username at the top right of the page, pictured below, which links to your profile.
You now have a copy of the repo on your GitHub account. Next, return to the terminal of the development Linode.
Push to the Forked Repo
Create files on the development Linode and push them to the forked repository on GitHub.
/test-repo-789 directory, create and checkout a new branch:
Create a project directory:
Create sample files:
Check the status of the Git project, with the git status command:
Add all the files in
/test-repo-789 to the Git staging area:
Push the new files to the forked repo on your new GitHub account. Replace SampleUser1234 below with your own GitHub username, and replace the repo name with the appropriate repo name if different:
Create a Pull Request Against the Original, Previously Cloned Repo
So far, Git was installed on a development Linode, a repo project was cloned to that Linode, a GitHub username was created, and a repo fork was copied to the GitHub user account. The final step is to ask the original repo project to accept the new revisions or sample files. This final process is called a pull request.
From the GitHub browser window, select your username from the top right of the page, pictured below.
At your GitHub profile, select the test-repo-789 in the center of the page, pictured below.
At the test-repo-789 page, select βbranchesβ.
Under βYour branchesβ, select βNew pull requestβ.
Check that the branch filters are set correctly.
Select the βCreate pull requestβ button.
Congratulations, you have used Git and GitHub for file sharing and version control. There are still many Git commands to learn, but you are off to a great start.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on Friday, February 6, 2015.
Cloning a repository
In this article
When you create a repository on GitHub.com, 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.
About cloning a repository
You can clone a repository from GitHub.com 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.com to your local machine.
Cloning a repository pulls down a full copy of all the repository data that GitHub.com 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.com, or pull other people’s changes from GitHub.com. For more information, see «Using Git».
You can clone your existing repository or clone another person’s existing repository to contribute to a project.
Cloning a repository
On GitHub.com, navigate to the main page of the repository.
Above the list of files, click
Copy the URL for the repository.
.
Change the current working directory to the location where you want the cloned directory.
Press Enter to create your local clone.
To learn more about GitHub CLI, see «About GitHub CLI.»
You can also use the GitHub URL to clone a repository.
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.com, 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
Change the current working directory to the location where you want the cloned directory.
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:
Help us make these docs great!
All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.
ΠΠ°ΠΊ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ GitHub Π½Π° ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅ Ρ Linux
GitHub β ΠΎΠ΄ΠΈΠ½ ΠΈΠ· ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ ΡΠ΅ΡΠ²ΠΈΡΠΎΠ² ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ² Π΄Π»Ρ ΡΠΎΠ²ΠΌΠ΅ΡΡΠ½ΠΎΠΉ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. ΠΠ½ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΠΊΠΎΠ½ΡΡΠΎΠ»Ρ Π²Π΅ΡΡΠΈΠΉ, Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΎΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΡ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ ΠΊΠΎΠ΄Π°, ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΡΡΡΠΎΠΊ, Π° ΡΠ°ΠΊΠΆΠ΅ ΠΎΠ½ Π±Π΅ΡΠΏΠ»Π°ΡΠ΅Π½.
Π Π΄Π°Π½Π½ΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½Ρ ΠΏΡΠΈΠΌΠ΅ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΡΠ΅ΡΠ²ΠΈΡΠ° Π½Π° ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅ ΠΏΠΎΠ΄ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΡ ΡΠΈΡΡΠ΅ΠΌ ΡΠ΅ΠΌΠ΅ΠΉΡΡΠ²Π° Linux. ΠΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ, ΠΊΠ°ΠΊ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π½Π° Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠΌ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅ ΠΈ Π·Π°Π»ΠΈΡΡ Π΅Π³ΠΎ Π½Π° ΡΠ΅ΡΠ²ΠΈΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ. Π Π°ΡΡΠΌΠΎΡΡΠ΅Π½Π½ΡΠ΅ Π²Π°ΡΠΈΠ°Π½ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ git ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠΈΠΌΠ΅Π½ΡΡΡ Π½Π° desktop ΡΠΈΡΡΠ΅ΠΌΠ°Ρ , Π·Π°ΠΏΡΡΡΠΈΠ² ΠΎΠΊΠ½ΠΎ ΡΠ΅ΡΠΌΠΈΠ½Π°Π»Π°.
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° git
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ git. ΠΡΠ»ΠΈ Π΅Π³ΠΎ Π½Π΅Ρ Π² ΡΠΈΡΡΠ΅ΠΌΠ΅, ΡΡΡΠ°Π½ΠΎΠ²ΠΊΡ ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΈΠ· ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ.
ΠΡΠ»ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ CentOS / Red Hat:
yum install git-core
ΠΡΠ»ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ Ubuntu / Debian:
apt-get install git
ΠΡΠ»ΠΈ ΠΌΡ Ρ ΠΎΡΠΈΠΌ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΡΠ΅ΡΠ²ΠΈΡΠΎΠΌ Ρ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ° Windows ΠΈΠ»ΠΈ Mac OS, Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΡΠΊΠ°ΡΠ°ΡΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ desktop Π²Π΅ΡΡΠΈΡ Ρ ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠ°ΠΉΡΠ°.
Π‘ΠΈΠ½ΡΠ°ΠΊΡΠΈΡ
ΠΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠΌΠ΅ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ:
* ΠΏΠΎΠ»Π½ΡΠΉ ΠΏΠ΅ΡΠ΅ΡΠ΅Π½Ρ ΠΎΠΏΡΠΈΠΉ, ΠΊΠΎΠΌΠ°Π½Π΄ ΠΈ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠΎΠ² ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡΡΠΈΡΡ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ man git.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π½Π° Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠΌ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅
ΠΡΠ΅ΠΆΠ΄Π΅ ΡΠ΅ΠΌ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π½Π° GitHub, ΡΠΎΠ·Π΄Π°Π΅ΠΌ Π΅Π³ΠΎ Π½Π° Π½Π°ΡΠ΅ΠΌ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ Π² ΠΊΠ°ΡΠ°Π»ΠΎΠ³ Ρ ΡΠ°ΠΉΠ»Π°ΠΌΠΈ ΠΏΡΠΎΠ΅ΠΊΡΠ°:
ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ Π΄Π»Ρ git:
ΠΡ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΎΡΠ²Π΅Ρ ΠΏΠΎΡ ΠΎΠΆΠΈΠΉ Π½Π°:
Initialized empty Git repository in /projects/.git/
ΠΡΠΎ ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ, ΡΡΠΎ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ git ΡΠΎΠ·Π΄Π°Π½.
Π’Π΅ΠΏΠ΅ΡΡ Π΄ΠΎΠ±Π°Π²ΠΈΠΌ ΡΠ°ΠΉΠ»Ρ Π² ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ:
* Π΄Π°Π½Π½ΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ ΠΌΡ Π΄ΠΎΠ±Π°Π²ΠΈΠ»ΠΈ ΠΏΠ°ΠΏΠΊΡ ΠΈ Π΅Π΅ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π² ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ git.
ΠΡΠΏΡΠ°Π²ΠΊΠ° Π΄Π°Π½Π½ΡΡ Π½Π° GitHub
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ Π΄Π°Π½Π½ΡΠ΅ Π½Π° ΡΠ΅ΡΠ²ΠΈΡ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Ρ Π½Π°Ρ Π΄ΠΎΠ»ΠΆΠ½Π° Π±ΡΡΡ Π·Π°ΡΠ΅Π³ΠΈΡΡΡΠΈΡΠΎΠ²Π°Π½Π½Π°Ρ ΡΡΠ΅ΡΠ½Π°Ρ Π·Π°ΠΏΠΈΡΡ ΠΈ ΡΠΎΠ·Π΄Π°Π½ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ Π½Π° GitHub.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ
ΠΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ Π½Π° ΠΏΠΎΡΡΠ°Π» github.com ΠΈ Π²Ρ ΠΎΠ΄ΠΈΠΌ Π² ΡΠΈΡΡΠ΅ΠΌΡ ΠΈΠ»ΠΈ ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΠΌ Π½Π΅ΡΠ»ΠΎΠΆΠ½ΡΡ ΡΠ΅Π³ΠΈΡΡΡΠ°ΡΠΈΡ:
ΠΡΠΎΡ ΠΎΠ΄ΠΈΠΌ ΠΏΡΠΎΡΠ΅ΡΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ, ΡΡΠΎ ΠΌΡ Π½Π΅ ΡΠΎΠ±ΠΎΡ. ΠΠ°ΡΠ΅ΠΌ Π·Π°Π²Π΅ΡΡΠ°Π΅ΠΌ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ°Π³ΠΎΠ² ΡΠ΅Π³ΠΈΡΡΡΠ°ΡΠΈΠΈ, Π½Π°ΠΆΠΈΠΌΠ°Ρ Submit. Π ΠΈΡΠΎΠ³Π΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΏΠΈΡΡΠΌΠΎ Π½Π° Π°Π΄ΡΠ΅Ρ ΡΠ»Π΅ΠΊΡΡΠΎΠ½Π½ΠΎΠΉ ΠΏΠΎΡΡΡ, ΠΊΠΎΡΠΎΡΡΡ ΡΠΊΠ°Π·Π°Π»ΠΈ ΠΏΡΠΈ ΡΠ΅Π³ΠΈΡΡΡΠ°ΡΠΈΠΈ. ΠΠ΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ Π±ΡΠ΄Π΅ΠΌ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠ΄ΠΈΡΡ email, ΠΏΠ΅ΡΠ΅ΠΉΠ΄Ρ Π² ΠΏΠΈΡΡΠΌΠ΅ ΠΏΠΎ ΠΊΠ½ΠΎΠΏΠΊΠ΅ Verify email address.
Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΊΠ»ΠΈΠΊΠ°Π΅ΠΌ ΠΏΠΎ ΠΈΠΊΠΎΠ½ΠΊΠ΅ ΠΏΡΠΎΡΠΈΠ»Ρ ΠΈ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ Π² ΡΠ°Π·Π΄Π΅Π» Your repositories:
Π ΠΊΠ»ΠΈΠΊΠ°Π΅ΠΌ ΠΏΠΎ ΠΊΠ½ΠΎΠΏΠΊΠ΅ New. Π ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΠΎΠΊΠ½Π΅ Π΄Π°Π΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ ΠΈ Π½Π°ΠΆΠΈΠΌΠ°Π΅ΠΌ Create repository:
ΠΡ ΡΠ²ΠΈΠ΄ΠΈΠΌ ΡΡΡΠ°Π½ΠΈΡΡ Ρ ΠΏΡΡΠ΅ΠΌ ΠΊ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ:
ΠΠ°Π»ΠΈΠ²Π°Π΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ Π² ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ Π½Π° GitHub
ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ ΠΊ Π½Π°ΡΠ΅ΠΌΡ ΠΏΡΠΎΠ΅ΠΊΡΡ:
* Π³Π΄Π΅ ΠΡΠ΅ΡΠ΅Π΄Π½ΠΎΠ΅ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ° β ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ»ΡΠ½ΡΠΉ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ; ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ -a ΡΠΊΠ°Π·ΡΠ²Π°Π΅Ρ, ΡΡΠΎ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ Π½ΡΠΆΠ½ΠΎ ΠΏΡΠΈΠΌΠ΅Π½ΠΈΡΡ ΠΊΠΎ Π²ΡΠ΅ΠΌ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½Π½ΡΠΌ ΡΠ°ΠΉΠ»Π°ΠΌ.
Π’Π΅ΠΏΠ΅ΡΡ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ°Π΅ΠΌΡΡ ΠΊ ΡΠΎΠ·Π΄Π°Π½Π½ΠΎΠΌΡ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ:
git remote add origin https://github.com/dmosktest/project1.git
* Π³Π΄Π΅ dmosktest β Π»ΠΎΠ³ΠΈΠ½, ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ» ΡΠΊΠ°Π·Π°Π½ ΠΏΡΠΈ ΡΠ΅Π³ΠΈΡΡΡΠ°ΡΠΈΠΈ Π½Π° github, Π° project1 β Π½Π°Π·Π²Π°Π½ΠΈΠ΅, ΠΊΠΎΡΠΎΡΠΎΠ΅ ΠΌΡ Π·Π°Π΄Π°Π»ΠΈ, ΠΊΠΎΠ³Π΄Π° ΡΠΎΠ·Π΄Π°Π²Π°Π»ΠΈ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ.
* ΡΠ΄Π°Π»ΠΈΡΡ ΡΠ΄Π°Π»Π΅Π½Π½ΡΠΉ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ ΠΌΠΎΠΆΠ½ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ git remote rm origin.
ΠΠ°ΠΊΠΈΠ΄ΡΠ²Π°Π΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ Π½Π° GitHub:
git push origin master
* Π³Π΄Π΅ master β Π²Π΅ΡΠΊΠ° ΠΏΡΠΎΠ΅ΠΊΡΠ° (Π²Π΅ΡΠΎΠΊ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ).
Π Π½Π°ΡΠ΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡΠ΅ Π½Π° GitHub Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΏΠΎΡΠ²ΠΈΡΡΡΡ ΡΠ°ΠΉΠ»Ρ ΠΏΡΠΎΠ΅ΠΊΡΠ°:
ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°ΠΉΠ»ΠΎΠ² Ρ GitHub
ΠΠ»Ρ Π·Π°Π³ΡΡΠ·ΠΊΠΈ Π½Π° ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ ΡΠ°ΠΉΠ»ΠΎΠ², ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ Ρ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠΌ ΠΈ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ Π² Π½Π΅Π³ΠΎ:
ΠΡΠΎΠ²ΠΎΠ΄ΠΈΠΌ Π½Π°ΡΠ°Π»ΡΠ½ΡΡ Π½Π°ΡΡΡΠΎΠΉΠΊΡ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ:
ΠΠΎΠ΄ΠΊΠ»ΡΡΠ°Π΅ΠΌΡΡ ΠΊ ΡΠ΄Π°Π»Π΅Π½Π½ΠΎΠΌΡ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ:
git remote add origin https://github.com/dmosktest/project1.git
Π‘ΠΊΠ°ΡΠΈΠ²Π°Π΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ:
git pull https://github.com/dmosktest/project1.git master
ΠΠ»ΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°
ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ Π½Π°Ρ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ:
git clone https://github.com/dmosktest/project1.git
* Π΄Π°Π½Π½Π°Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π° ΡΠΎΠ·Π΄Π°ΡΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΠΏΠ°ΠΏΠΊΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ project1 ΠΈ ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ Π΅Π³ΠΎ ΠΊΠ°ΠΊ Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ git. Π’Π°ΠΊΠΆΠ΅ Π·Π°Π³ΡΡΠ·ΠΈΡ ΡΠ°ΠΉΠ»Ρ ΠΏΡΠΎΠ΅ΠΊΡΠ°.
ΠΠΎΠ·ΠΌΠΎΠΆΠ½ΡΠ΅ ΠΎΡΠΈΠ±ΠΊΠΈ
1. ΠΡΠΈ ΠΏΠΎΠΏΡΡΠΊΠ΅ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ Π΄Π°Π½Π½ΡΠ΅ Π½Π° GitHub, ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΎΡΠΈΠ±ΠΊΡ:
error: src refspec master does not match any.
error: failed to push some refs to ‘https://github.com/dmosktest/project1.git’
* Π³Π΄Π΅ dmosktest/project1.git β ΠΏΡΡΡ ΠΊ Π½Π°ΡΠ΅ΠΌΡ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ.
ΠΡΠΈΡΠΈΠ½Π°: ΠΏΡΠΎΠ΅ΠΊΡ Π½ΠΈ ΡΠ°Π·Ρ Π½Π΅ Π±ΡΠ» Π·Π°ΡΠΈΠΊΡΠΈΡΠΎΠ²Π°Π½ (Π·Π°ΠΊΠΎΠΌΠΌΠΈΡΠ΅Π½).
Π Π΅ΡΠ΅Π½ΠΈΠ΅: Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ ΠΊ Π½Π°ΡΠ΅ΠΌΡ ΠΏΡΠΎΠ΅ΠΊΡΡ:
How to Create and Clone a Repo in GitHub on Ubuntu 18.04
GitHub is a free repository hosting service, used as version control for web developers to download and push their code from their servers to other users.Π In our previous article on Installing Git on Ubunto 18.04, we’ve instructed on how to add Git to your Ubuntu VPS server. We’ll continue on and show you how to add and clone a repo from GitHub to your server.
Preflight
Step 1: Set up a GitHub Account
If you havenΠ²Π™t done so already, make a Github.com account, itΠ²Π™s free! This is where youΠ²Π™ll be creating a repo and putting in files. Π Once youΠ²Π™re in your GitHub account, click Create a repository (or New Repository), which will take you to a page where you can add details for your repo.
Step 2: Create a Repo
Fill out the details for your repo and be sure to take note your repo name, youΠ²Π™ll need it later in this tutorial. Π If you are curious about the options on this screen, the README file is common for writing instructions to your users. Π The licensing option can seem confusing but if you are questioning which one to choose you can check out this site to guide you. Once all details are in, click Create repository.
Once created, youΠ²Π™ll see two files in your repository if you chose the licensing and README file.
Step 3: Configuring Git per User
Step 4: Create A Directory
When you create a directory, you can use this space to sync newly written/edited code to your GitHub account. IΠ²Π™m going to call this environment git_environment and move into the directory using the cd command.
Step 5: Copy your GitHub URL
First, its necessary to clone or download our already pre-existing README and licensing file from our GitHub account. Π Jump back to your GitHub account, click Clone or download and copy your GitHub link.
Step 6: Clone your Repo
In your terminal, you should find yourself in the GitHub directory. Π We will first clone our repo with our copied GitHub URL and then change directories to our project name.
git clone https://github.com/username/want-some-java.git
By listing the want-some-java directory, youΠ²Π™ll see the two files in your repo, verifying that the cloning has worked.
Example Output: LICENSE Π README.md
In our next tutorial, where will teach you how to edit/create a file on your server and push the script to your GitHub account.
Our talented Support Teams are full of experienced Linux technicians and System administrators who have an intimate knowledge of multiple web hosting technologies, especially those discussed in this article. We are always available to assist with any issues related to this article, 24 hours a day, 7 days a week 365 days a year.
If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined, we can be reached via phone @800.580.4985, a chat or support ticket to assisting you with this process.
Related Articles:
About the Author: Alex Gorzen
Alex Gorzen has been helping others with technology his whole life. He played with computers even before he could read and wants to make sure his children share that same love as they grow up. In his free time, he enjoys gardening, building things, and learning new skills.
Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business
How to clone a private repository in Github
Git is an open-source, version control tool created in 2005 by developers working on the Linux operating system.
Cloning public repositories from Github or Gitlab using git is pretty straightforward, but when it comes to handle a private one, sometimes the situation is a bit tricky. You can either clone a private Github repository with a password like you normally would with any other online service, or do it with a token if you enabled 2-factor-authentication on your account or your organization uses SAML SSO. Alternatively, you can also clone private Github repo with SSH credentials.
In this article, we will show you how to clone a private repo using git with both a password and a Github token. We will also cover possible solutions to the common βRepository not foundβ error message when you try to clone a private repo from Github.
Prerequisites
In order to clone a git repository, you obviously need to have Git installed on your computer.
To check if Git is correctly installed on Windows or Linux, execute the following command :
Now that you know that Git is correctly installed, youβre ready to start cloning private Github repositories.
Clone private Github repo with username/password
In a few moment, you will be prompted for a password. Once you input the correct one, the output should look something like this :
Alternatively, if you donβt really care about exposing your password in plain text, you can put it directly in the repository URL :
Important: Private repositories cannot be cloned using git protocol.
You can configure git to specifically use HTTPS over other protocols by setting hub.protocol global flag to https. This will affect all git operations, including clone, fork, remote add and other operations that expand references to GitHub repositories as full URLs.
Clone private Github repo without typing password
Using an username/password pair, you have to input the password every time you want to push, pull or do operations to the repo. This behaviour can be annoying at times. Luckily, you can permanently store your password in git configuration file so you wonβt be prompted ever again.
First, you have to enable the credentials helper by setting the credential.helper flag to store.
Clone private Github repo with SSH keys
To be able to clone from Github using SSH, you must generate an SSH keypair on your computer and add the public key to your GitHub account. Github documentation has extensively covered the process at Connecting to GitHub with SSH.
Next, you have to find the repository SSH URL from Github repo page.
Click Use SSH and the SSH URL should be displayed in a second.
This SSH URL works exactly the same way username/password pair does, except you donβt have to enter a password because it is already stored on your system in the form of a private key.
Clone private Github repo with token
In order to clone a Github repo with a 2FA-enabled Github account, you need to use a personal access token instead of entering the password. This Github token also allows you to login to organizations that uses SAML single sign-on β a technology used to control who can access which part of the repository.
Head over to Github dashboard. In the upper-right corner of any page, click your profile photo, then click Settings.
In the left sidebar, click Developer settings.
You will be redirected to Github Apps page. In the left sidebar, click Personal access tokens and then Generate new token.
You have to give your token a descriptive name and grant it the permission to access your repositories. To use your token to access repositories from the command line, select repo. Finally, click Generate Token button at the end of the webpage.
At this stage, you have to copy the token and securely save it elsewhere. For security reasons, after you navigate off the page, you will not be able to see the token again.
Treat your tokens like passwords and keep them secret because they are actually your password to some extent.
Once you have the token, you can use it just like a password. Whenever you are prompted for password, input that token. The token is pretty long and hard to remember, so I recommend you saving it to avoid type it again and again.
βRepository not foundβ error when clone a private repo
If you see this error message when cloning a private Github repo, it basically means that the repository does not exists (of course) and you donβt have the permission to access it.
On Linux, try clearing saved credentials from your system with the following command.
On a MacOS device, you can go to Keychain Access, find the credentials related to Git and Github, then change the username and password to the correct value.
If you still get the error, despite following all above solutions, you can try reinstalling gitβs credential-manager using these commands.