V
V
Vadim2019-10-18 11:19:35
git
Vadim, 2019-10-18 11:19:35

How do tags work in Git?

Some time ago I downloaded the repository to my local computer. After that, others continued to develop it, adding new commits to the develop and master branches. Also added tags (3.1-beta, 4.0-beta) to some commits in the develop branch.
I need to convert the code in the current project folder to version 4.0-beta, for this I execute in its local folder:

git fetch
git checkout 4.0-beta
git status

The response of the last command is:
HEAD detached at с
nothing to commit, working directory clean

My understanding is that I have two copies of the project after cloning it with git clone: ​​local and local-synced (both available locally). After the git fetch command, the entire local-synced copy is updated. Then I switch to a commit with the 4.0-beta tag and, accordingly, all files in the current project directory correspond to this commit. Therefore, I can compile them and be sure that they are of this particular version. If I run git merge, the local-synced copy will be depleted from the local one. But in fact, I don’t have to do this if I don’t want to change these files, but only use them.
If my reasoning is wrong, can you correct it? Why does git status say Head Detached?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lorc, 2019-10-18
@lorc

Yes, everything is correct in general terms. In addition to the point about git merge.
Head Detached because you checked out a specific commit, not a branch. Accordingly, you are not "located" in any branch. What the git tells you. You can do it git checkout -b my-new-branchand then this message disappears because you will create a new branch on the current commit and switch to it.

N
netrox, 2019-10-18
@netrox

https://stackoverflow.com/questions/35979642/what-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question