Then push it, with either git push origin name or git push -tags.ġThe master~2 syntax instructs git to start at the commit found via master, then back up two steps. Use whatever viewer you like to make sure it's set correctly. To set a tag in the remote, first set it locally, with git tag name commit-identifier. You can leave out the name origin if you don't need it to make all the arguments, e.g., git push -tags is the same as git push -tags origin (assuming all your pushes go to origin, anyway). (In fact, that fourth argument is a pair of names, like master:master or sometag:sometag, but it defaults to using the same name on both sides in most cases. Just as you can push a specific branch: git push origin master To push a specific tag, you can name it: git push origin sometag To push all your tags, you can simply add -tags to your git push command: git push -tags origin (That is, git push master tries to use master as a remote-name rather than a branch-name.) If you leave it out, git will try to figure one out, but if you want to add a branch or tag name, you need to include it explicitly, since the first word here is assumed to be the remote-name. The argument after git push names the repository (generally via a "remote" name, like origin) to push-to. 3 These names (branches, tags, and so on) are called "references" in general, but let's just use "branch" and "tag" for now. When you use git push, what you're really doing is instructing some other git repository to take any new commits you have that they don't, and then set some name(s)-usually branches and/or tags-to point to some commits (one each) in the resulting collection. Any time you move a branch so that this rule is violated, you're "rewriting history" see other articles for when this is fine, and when it causes people trouble.) Pushing tags 2 Branches are generally expected to move in a "forward" direction, i.e., if master used to point to commit C and now points to commit D, commit C should usually be found by starting at D and working backwards. The real difference is that tags are not expected to move, while branches are and git won't move tags automatically. Will delete tag sometag, after which: $ git tag sometag master~2 You can, at any time, create or delete any tag pointing to any particular commit: $ git tag -d sometag If you then make a new commit D, git advances the branch, but not the tag: A <- B <- C <- D <- master If you make a tag now, that tag will, by default, point to commit C: A <- B <- C <- master Then when you make a third commit, git again makes it point back to its parent commit, and advances the branch: A <- B <- C <- master When you make the second commit, git creates B pointing back to A, and advances the branch name to point to B: A <- B <- master The first commit ( A) points to nothing, as it's the first commit, and branch master points to A: A <- master To see how this works, consider a simple git repository with just three commits. Thus, the main difference between a branch and a tag is that a tag does not move. That is, as you add new commits-in some ways, that's mostly all git does: add new commits to its collective, sort of like the Borg from the old Star Trek TNG series-whatever branch you're on, that's the branch that gets re-adjusted to point to the new commit.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |