0

The purpose of this project is to call code not in the standard UNIX path.

My professor has provided steps to clone gawk from a GIT repository and then build and install in an autoconf format.

MY PROBLEM IS - After cloning from git://git.savannah.gnu.org/gawk.git I need to change the version I am going to install. When I use the git checkout tags/gawk-3.1.8 command that the professor has provided us with I receive the following output. When i use the make and make install commands I end up with the latest version of gawk and not 3.1.8.

Note: checking out 'tags/gawk-3.1.8'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by perfoming another checkout.
If you want to create a new branch to retain commits you create, you may do
so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 00ef042... Move to 3.1.8

I have searched several detached HEAD state forums but have not been able to reach a solution. Any help is appreciated.

Joe
  • 3
  • 3
  • What is the problem? Are you going to modify gawk and make your own commits? If so, just create a branch after you check out the tag. If you are installing, then just run the build script and you are done. – Code-Apprentice Feb 23 '18 at 18:24
  • Why do you think you "end up with" anything but gawk 3.1.8? I think you're not running the version you built. – jthill Feb 23 '18 at 18:56

2 Answers2

1

This is not an error, everything worked as expected. Notice how the output says Note: and not Error: or something.

The note is simply telling you that are in a "detached HEAD" state which is fine if you are just using the repo and don't intend to push any commits.

  • That is certainly odd, I assume you tried `git status` to make sure you didn't accidentally merge something and are definitely on `tags/gawk-3.1.8`? – Ian Colwell Feb 23 '18 at 18:33
  • Yes, you are a little off-base :) if `git status` told you that you were on gawk-3.1.8 then the code in the repo is the code that was tagged as such and that is definitely the code you are using. How are you sure you aren't building 3.1.8? did you try a `make clean` and build/install again? – Ian Colwell Feb 23 '18 at 18:54
  • When I checked the version using ./bin/gawk --version versus /bin/gawk --version it gave me the 3.1.8. Would you mind explaining to me why that was? – Joe Feb 23 '18 at 19:05
  • ahh, this is most likely because you now have installed 2 versions of gawk. The one located at /bin/gawk is version 4.0.2 (this one was likely already installed via `apt`) and the one you installed locally (wherever you cloned the repo to) is version 3.1.8. If you type `which gawk` it will tell you which copy of gawk is in your PATH and therefore which one will be used by default. – Ian Colwell Feb 23 '18 at 19:11
  • Thank you so much. If I need to change which gawk is used how would I do that? – Joe Feb 23 '18 at 19:18
  • 1
    Depends what you plan to use the old gawk for, if it is just for some temporary school project or something, I would leave it where is and use it directly with the full path. If you want to downgrade gawk for your whole system and keep it that way then you can run `sudo apt remove gawk` and install the source version. Try googling around a bit for stuff like "installing software from source" etc. – Ian Colwell Feb 23 '18 at 19:34
0

your detached HEAD state isn't necessarily a "problem" that you need to solve. I understand that the printed warning may alarm you, but it is just Git trying to prevent you from making a mistake.

Detached HEAD just means that your HEAD reference isn't pointing to any other reference than the commit.

In other words: you aren't on a branch. That's not a problem that needs solving, you should be able to just checkout that version as you have done and build the project according to the instructions provided by your professor.

Read more here: https://git-scm.com/docs/git-checkout#_detached_head

xtianjohns
  • 706
  • 3
  • 12