![]() ![]() Configure IntelliSense for cross-compiling.# Note that we now have first as a local branchīranch 'second' set up to track remote branch 'second' from 'origin'. Remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 0īranch 'first' set up to track remote branch 'first' from 'origin'. Remote: Compressing objects: 100% (3/3), done. Remote: Counting objects: 100% (9/9), done. Note: additional comments below are prefixed with # clone demo repo to local machine The demo.git repo has two branches named first and second contain only one file README.md the content of which is different each of the branches.Ĭlone the repository, list the branches, switch to the branch of interest. The solution below is based on a demo repository on created solely for the purpose of this answer. I had a similar problem with repo on with 2 branches. Once you do have your (non-mirror) clone, and their whatever becomes your origin/ whatever, you can git checkout whatever and the DWIM action I mentioned (and linked) above comes into play, creating a new local whatever using your own origin/ whatever-which you copied from their whatever! If you want to get their remote-tracking branches, you can-but you need to name them something else! This leaves no room for their origin/*, because your inexact-copy has its own origin/*. Their master becomes your origin/master their iOS becomes your origin/iOS. The fundamental idea here is that you want all of their branch names to become your remote-tracking branch names. The main point of most git clone operations is to get an inexact copy of "their Git". This copies all the references from the other Git at origin, but it means you cannot have your own branches: your Git is now an exact copy of theirs, and every time you run git fetch you replace everything you have with. Using git clone -mirror tells your Git to set up a bare repository (which I'll leave undefined here) and to set up +refs/*:refs/* as the refspec for git fetch. ![]() ![]() When you git push, the source references are yours and the destination ones are theirs. When you git fetch, the source references are the other Git's references and the destination ones are yours. The reference before the colon is the source and the reference after the colon is the destination, and this matters because there are two Gits involved in git fetch and git push: yours, and some other Git. Both git fetch and git push work with refspecs (and both have a -force flag of their own, which effectively adds a + to any refspecs you give on the command line). You can prefix a refspec with a leading plus sign as well this sets the -force flag. For instance, refs/heads/*:refs/remotes/origin/* is a refspec. To keep this short: a refspec is just a pair of references, separated by a colon, and sometimes with one part replaced with *. This explains why you see what you see, but not what happens with git clone -mirror, nor why you can git checkout iOS and suddenly have a new refs/heads/iOS and for that we need two more items, about refspecs (as used with git fetch and git push), and about what Git calls DWIM, or Do What I Mean, in git checkout. When you run git branch -a, Git finds both, and shows the first with refs/heads/ stripped but shows the second with just refs/ stripped. When you run git branch -r, Git finds all your refs/remotes/ references and shows them with refs/remotes/ stripped off. When you run git branch, Git finds all your refs/heads/ reference names and shows them with refs/heads/ stripped off. There are yet more forms of references ( refs/notes/ is for Git's git notes, and GitHub uses refs/pull/ for instance) but branch, tag, and remote-tracking branches are all built in, and standard, and most importantly, highly visible-so you should know about them. To complete this particular list, a tag name like v1.0 is simply a reference whose full name starts with refs/tags/. However, the fact that the name of the remote gets a slash added afterward is tied to the reason you should be careful about using slashes in your remote names.) (The remote part of this is an almost-arbitrary string. The last part, iOS, is something your Git normally copies from another Git. Git also has tags and what Git calls remote-tracking branch names, and these all fall into a general category called references.Ī branch name like master is simply a reference whose full name starts with refs/heads/.Ī remote-tracking branch name like origin/iOS is a reference whose full name starts with refs/remotes/, followed by the name of the remote itself ( origin) and another slash. The first is that while Git has branch names, that's not all that Git has (and for that matter, the term branch is ambiguous: see also What exactly do we mean by "branch"?). There are a few separate, but intertwined, key concepts here. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |