I fully admit I am new to Git (I used Github's Mac GUI client for a year and recently decided to get a little more advanced by using SourceTree), but I'm confused about SourceTree's behavior when I freshly clone a repository from Github. The Github repository has multiple branches. When I used GitHub for Mac GUI to clone a repository with multiple branches, the entire repository and all its various branches would get cloned to my local machine.
However when I use SourceTree to clone a repository from Github, SourceTree only clones the single branch that I list in the clone dialog. Is this expected behavior or is Github for Mac's behavior the "expected" way? How can I make SourceTree clone the entire repository and all its branches to my local machine?
When you clone a Git repository, you have access to all of the remote branches and the full repository, you'll just need to checkout the appropriate branch. By default SourceTree checks out only the default branch during a clone. You'll need to checkout the remote branch and have it track locally.
In SourceTree if you want to checkout one of these remote branches, look for the branch on the left-hand side under remotes. You can then right-click on a branch and select checkout.
You can only checkout one branch at a time in Git. A checkout in Git updates your local files to the state of that commit/branch.
You still have access to all the branches of the remote repository through the remotes menu on the left. You can create a remote-tracking branch by right-clicking on any of them and selecting checkout. Once you do that, the branch will appear under the local menu on the left. I haven't been able to find a way to do this in bulk.
So, by doing the clone, you do have access to all of the branches from the GitHub repository. Does that help with what you're trying to accomplish?
Yes I think so! I'm slightly still confused because when I cloned a repository using the GitHub Mac GUI, all of the remote branches would appear (in some way) on my local machine so that I could switch between them when my local machine was not online (e.g. while flying). I guess maybe GitHub Mac was automatically creating remote-tracking branches on my local machine for every branch in the remote?
If I'm understanding you properly, it sounds like after cloning a new repository, I should create remote-tracking branches for each remot branch I might want to access offline.
I haven't used the GitHub Mac GUI so I'm not sure what it was doing, but in SourceTree you should still have access to the Remotes section on the left-hand side and be able to checkout remote branches even while offline (at least it appeared to work when I disconnected my network).
I don't think you should have to create remote-tracking branches ahead of time.
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG