Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 218269
Next
Alex Hales
  • 0
Alex HalesTeacher
Asked: July 14, 20222022-07-14T13:54:57+00:00 2022-07-14T13:54:57+00:00In: Git, git-branch, git-clone, remote-branch

git – How do I clone all remote branches?

  • 0

[ad_1]

All the answers I saw here were valid, but there is a much cleaner way to clone a repository and to pull all the branches at once.

When you clone a repository, all the information of the branches is actually downloaded, but the branches are hidden. With the command

git branch -a

you can show all the branches of the repository, and with the command

git checkout -b branchname origin/branchname

you can then “download” them manually one at a time.


However, when you want to clone a repository with a lot of branches, all the ways illustrated in previous answers are lengthy and tedious in respect to a much cleaner and quicker way that I am going to show, though it’s a bit complicated. You need three steps to accomplish this:

1. First step

Create a new empty folder on your machine and clone a mirror copy of the .git folder from the repository:

cd ~/Desktop && mkdir my_repo_folder && cd my_repo_folder
git clone --mirror https://github.com/planetoftheweb/responsivebootstrap.git .git

The local repository inside the folder my_repo_folder is still empty, and there is just a hidden .git folder now that you can see with a “ls -alt” command from the terminal.

2. Second step

Switch this repository from an empty (bare) repository to a regular repository by switching the boolean value “bare” of the Git configurations to false:

git config --bool core.bare false

3. Third Step

Grab everything that inside the current folder and create all the branches on the local machine, therefore making this a normal repository.

git reset --hard

So now you can just type the command “git branch” and you can see that all the branches are downloaded.

This is the quick way in which you can clone a Git repository with all the branches at once, but it’s not something you want to do for every single project in this way.

[ad_2]

  • 0 0 Answers
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 2 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 4 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 3 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.