Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"git status branch" reports detached HEAD #2418

Open
mknejp opened this issue Jun 6, 2018 · 5 comments
Open

"git status branch" reports detached HEAD #2418

mknejp opened this issue Jun 6, 2018 · 5 comments

Comments

@mknejp
Copy link

mknejp commented Jun 6, 2018

Hi,

we used to use "git lfs clone" in a custom clone script but started getting "git lfs clone is deprecated" warnings.
So we ditched our custom script in favor of the appveyor default, however we now have problems getting the branch number in our build scripts. The branch number is part of our detailed version and is read using "git status branch" (so that it works everywhere, not just on the CI).

However it seems that even though appveyor does use the branch name in the clone, it does not use it in the checkout:

git clone -q --branch=XXX git@bitbucket.org:user/repo.git C:\projects\project
Filtering content:  ...
git checkout -qf 01234abcd...

I don't know why the git checkout command is there but that's responsible for dropping us on a detached HEAD. If the clone script already has a --branch specified, what is the purpose of git checkout?

Thanks

@MSP-Greg
Copy link

MSP-Greg commented Jun 6, 2018

Makes sense. After all, if one needs the first commit in the branch git log --pretty=format:%H -1 or git log --pretty=format:%h -1 can be used...

@FeodorFitsner
Copy link
Member

git checkout -qf 01234abcd... is required to checkout build's specific commit; otherwise you'll be getting the latest commit on XXX branch.

@MSP-Greg
Copy link

MSP-Greg commented Jun 6, 2018

Understood. Although I can understand the mentioned issue, you need the checkout for when several commits are done faster than the builds run, assuming a build is done for every commit.

@mknejp
Copy link
Author

mknejp commented Jun 7, 2018

How about doing git reset --hard -q 01234abcd... instead? Would that not also rewind the current branch's head?

@MSP-Greg
Copy link

MSP-Greg commented Jun 7, 2018

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants