Now all the necessary tools are ready. They need to be applied on something. Something here is the GitHub repository.
Before we start, let's clarify a pair of terminology: Fork and clone. Both can get you a copy of GitHub repository. So what's the difference?
Fork a repository means to create a copy of repository on GitHub server side. The physical copy resides remotely. Usually the purpose of fork is to start a new project based on the code from the old repository, and create a separate community around it. The reality is that those who fork a project rarely, if ever, return back to the original repository, or in more Git professional term, create a pull request to contribute to the parent project.
On the other hand, clone a repository is to get a copy of repository to local machine. Its primary purpose is to make the change to the code, and contribute back to original repository. At this stage of the tutorial, we will only deal with clone a repository to our local computer.
After we have clarified the difference between fork and clone, you may have another question if you have used CVS or SVN before: why don't we call the process of cloning a repository like in old days as "checkout a repository into a sandbox"?
The short answer is: git clone is similar or an analogue to SVN checkout.
But maybe a long answer would make it more clear. Git clone will get you the whole repository. I mean everything, a full fledged repository, having its own commit history, revision history, etc. Practically, you can work offline with your local repository.
SVN checkout, on the other hand, will give you a working copy of the central repository, without all the commit history, revision history, etc. So you have to connect to central server when commit the code. In other words, SVN working copy is not the full repository.
Furthermore, Git checkout has different meaning. Checkout in Git could mean switching between branches in local repository, or creating a new branch, or restore files from other revision.
So you see, to avoid possible confusion, let's just say "clone" when talking about retrieving a GitHub repository to local machine.
That's enough for the definitions.
Let's clone a GitHub repository to local machine. First go to GitHub repository of your choice. Copy the HTTPS web URL by clicking the green button on the web page. Then come back to the local machine, run git clone command with the GitHub repository address we just copied.
Here is a quick demo of git clone command working in PowerShell Console:
change to c:\temp directory. You can certainly go to any other directory
type "git clone" then paste the GitHub repository address with Ctrl + V shortcut
press Enter to execute the command
since I am using a small demo repository, it takes several seconds to finish
Now we have a local GitHub repository. Change directory to this new folder. You may notice we have the Git status summary information at prompt, because we have installed and imported posh-git module. We are now at master branch. It is synchronized with remote repository.
Use "dir" or "ls" to take a look at the files in local repository. If it's a new repository, there is only one file: README.md.
To practice what you have learned, delete this local repository, and clone it again. When you are ready, please move on. In next lesson, we will start working on master branch, adding a file to staging area, committing to local repository, then pushing to remote repository.
Thanks for watching!
На этой странице сайта вы можете посмотреть видео онлайн GitHub tutorial 07: Clone repository длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь LiLeoWang 31 Май 2019, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 112 раз и оно понравилось 2 зрителям. Приятного просмотра!