- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to clone a GitHub repository?
Cloning a repository involves downloading a copy of the source code from source control. In other words, cloning is creating a copy of an existing repository. Consider an example where multiple users are working on a project. This feature can be used by the users to create a development copy.
If you have a GitHub repository, you need to first invite collaborators into the repository. Each collaborator will then clone the repository into their local machines.
Locally they will work with this cloned repository, make local changes and perform commits on it. Once they are ready to share their changes with others in the team, they will push the commits to the central repository.
In order to clone a repository, we need to follow the steps given below −
Copy the URL from the text box shown above and paste this into your git bash terminal using the below command.
$ git clone {repo_rul}
This will create a folder in your machine with the same name as that of the project.
$ dell@DESKTOP-N961NR5 MINGW64 /e/tut_repo $ git clone https://github.com/kannan/sample.git Cloning into 'sample'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. $ dell@DESKTOP-N961NR5 MINGW64 /e/tut_repo $ ls sample/
Change the current working directory to the project folder and execute the git log command as shown below
$ dell@DESKTOP-N961NR5 MINGW64 /e/tut_repo $ cd sample/ $ dell@DESKTOP-N961NR5 MINGW64 /e/tut_repo/sample (main) $ git log --oneline --all --graph * b494547 (HEAD -> main, origin/main, origin/HEAD) Initial commit
In the above output, origin is the name given by git for the remote tracking branch (i.e., the source branch that was cloned). origin/main and origin/HEAD are remote tracking branches. In order to view the details of the remote tracking branch use the following command
$ git remote -v origin https://github.com/kannan/sample.git (fetch) origin https://github.com/kannan/sample.git (push)
-v means verbose so this will list the details of the remote tracking branches.
- Related Articles
- How to create a GitHub repository
- How to add collaborators to a repository in GitHub?
- How to Host Files using GitHub?
- How to Get GitHub Slack Integration?
- How to download a Tarball from GitHub on Linux?
- How to upload a project to GitHub from VS Code?
- How to Clone a List in Java?
- How to Clone a Map in Java
- How to clone a canvas using FabricJS?
- How to copy or clone a Java ArrayList?
- How to clone a Date object in JavaScript?
- How to copy or clone a C# list?
- How to clone a generic list in C#?
- How to remove a committed file from the Git repository?
- How to ignore a previously committed file in Git repository?
