News Stay informed about the latest enterprise technology news and product updates.

How to clone from a git tag example

The git clone tag example

A git tag typically represents a development milestone, a release candidate or some point of software stability achieved within the lifecycle of the development process. As such, it’s not unreasonable to think that at times, it would be necessary to perform a git tag clone rather that a clone from tip of a development branch. It’s not hard to do, either. Just perform the clone and specify the tag name with the branch option.

git clone tag example target

This git clone tag example will focus on tag 1.0.0-rc.1.

git-clone@tag:~$ git clone --branch 1.0.0-rc.1 http://gitlab.mcnz.com/root/gitlab-made-easy.git

The detached head

As mentioned, there are times when it makes sense to perform a git clone tag operation. However, it does come with a catch.

Normally, when you check out a branch, your workspace or working tree is updated with the code from the last git commit. From there, you can edit code, add files and subsequently commit and push to origin until your hearts content. However, a tag is normally in the middle of a long commit history. There are commits before it and there are commits after it. This creates an unusual situation, as you can’t add any new commits without disturbing the git blockchain.

detached git clone tag head

The git clone tag operation can lead to a detached head.

As such, when you git clone a tag, there is a good chance you will end up in a detached head state. This isn’t the end of the world. You can compile the code you pulled down from your GitHub or GitLab server without a problem. But you won’t be able to make changes and easily merge back to master. You’ll have to jump through some hoops if you plan to do so.

But if that simply caveat about the detached head doesn’t scare you off, don’t hesitate to perform a git clone tag. In many instances, especially when working with git submodules or running continuous integration pipelines, a git clone tag operation makes sense.

Become a Git power user

Want to become a Git power user? Take a look at the following Git articles and tutorials

 

 

 

 

 

 

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

What about ltfs? A few companies are working on search tools for tape.
Cancel

-ADS BY GOOGLE

SearchAppArchitecture

SearchSoftwareQuality

SearchCloudComputing

SearchSecurity

SearchAWS

Close