Question about using Process with git

Hi, recently I implemented something special to target specific version for some git repositories. I use Process with the command git.

The problem is, how can I check if a git repository actually focused on a tag or not ? I didn’t found how to check that

In one word: my software download a repository.
Sometime, it will modify the current branch or tag, by using:
git switch --detach

After this command, I would like to check in this repository if it detached to master, or a tag…etc → I just would like to get the name (master, alpha-06012023 …etc)

Hello,

You could inspect .git/HEAD file instead, as it will give you the reference to the branch or the commit (in the case of detached):

$ git status
On branch main
nothing to commit, working tree clean

$ cat .git/HEAD 
ref: refs/heads/main

$ git switch --detach 
HEAD is now at 8eebc39 Initial import

$ git status
HEAD detached at 8eebc39
nothing to commit, working tree clean

$ cat .git/HEAD 
8eebc39d5219b248c1975352fcb7383ec1ce899b

Hope that helps.

Thank you to write this. I knew already that.

But I would like to understand after I did a git switch --detach Alpha-06012023, how can I come back to master properly?

Because before I performed a switch --detach, when I typed in the terminal this, I got:

zohran@alienware-m17-r3 ~/Documents/Programmation/ISM $ git describe --all
heads/master

But now, even I do a switch to the master branch, I have always something like that:

zohran@alienware-m17-r3 ~/Downloads/ism $ git describe --all
tags/Alpha-06012023-a

Hello,

Sorry didn’t interpret your original request, I thought you wanted to know how to tell if you were detached or not.

Given the following repo history:

$ git log --oneline 
ac31d22 (HEAD -> main, tag: v2) A third change
e10100b (tag: v1) Another change
8eebc39 Initial import

When I do the commands you’re showing this time, I get the following:

$ git describe --all 
tags/v2

That is because HEAD is pointing to the last commit that is tagged as v2.

The moment I add another commit, describe shows the branch instead:

$ git ci --allow-empty -m "a 4th commit"
[main 007f9b7] a 4th commit

$ git log --oneline 
007f9b7 (HEAD -> main) a 4th commit
ac31d22 (tag: v2) A third change
e10100b (tag: v1) Another change
8eebc39 Initial import

$ git describe --all 
heads/main

Is perhaps the commit you’re detaching from and the branch you’re coming back to the one under the same tag you’re referencing?

If I detach from a previous commit, I got another tag as referenced:

$ git switch --detach e10100b
HEAD is now at e10100b Another change

$ git describe --all
tags/v1

Hope that helps.