Ali Hashmi
Ali Hashmi

Reputation: 161

how to clone all branches and not just master in Atom Text Editor

I have a repository on Github which consist of two branches. I am trying to use Git-Plus:Clone in Atom to try to clone all repositories. However, all my attempts have failed and only the master branch gets cloned. I have looked this problem up on SE but could not find a way to do it. Can someone kindly help me figure this out. Thanks in advance !

Upvotes: 6

Views: 7233

Answers (2)

Mr Janitor
Mr Janitor

Reputation: 81

In Atom, install Git Plus package in Preferences, then toggle command palette (on mac it's cmd+shift+p) and type checkout, select "Git Plus: Checkout Remote" from the suggested list of items in the drop-down menu.

Then you just need to select the target repo and branch you wish to check out and the remote branch will become local and you will be able to work on it and switch between different branches.

Upvotes: 2

Schwern
Schwern

Reputation: 165546

However, all my attempts have failed and only the master branch gets cloned.

This behavior is not unique to Atom. It's the normal git clone behavior.

All branches are cloned, but git clone will only automatically make a local branch for master or whatever the default branch for the repository is. The rest remain as "remote tracking branches", local copies of the remote. They're on your disk, but they're effectively read-only. Git does this to avoid flooding your clone with possibly a bazillion irrelevant local branches, should the project you're cloning have a lot of branches.

For example, if your remote has master, foo, and bar. You will wind up with origin/master, origin/foo, origin/bar, and master. origin/... are all remote tracking branches. They remember the state of the remote repository the last time you looked at it (with a git clone, or fetch or pull).

master is a local branch of origin/master for you to work on. If you want to work on another branch, make a local version of it. For example, git checkout -b origin/foo foo would create a local foo for you to work on (or however you do it in Atom).

See also this answer.

Upvotes: 5

Related Questions