Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Getting Started With Git Looking Back on What We've Done

Fatal message when git checkout

Hi, i don't know if this is a problem but when i type "git checkout <hash_number>" git return to that point but appear this message like:

Note: checking out <hash_number> ..... fatal: ref HEAD is not a symbolic ref

And every time a type a command this "fatal: ref HEAD is not a symbolic ref" appear. Should i do something?. Also appear this when i navigate over .git folder "fatal: This operation must be run in a work tree".

PD: I returned to master and only when im on master everything is ok.

Hey Alex!

Is there a specific branch that you're trying to checkout when you're using "git checkout"? For instance: "git checkout mynewbranch".

It's not a branch it is a commit. On the video the teacher did it and its ok but when i did it that message appear.

4 Answers

Hi, Alex. "checkout" and "commit" are different commands. Use "checkout" to change directories and "commit" to save your changes. Would it be possible for you to post your commands here so we can get a better idea of what you're looking at?

Hi, Michelle. Thanks for your response. This is what i did:
➜ jettcom git:(master) ✗ git log --oneline</p>
0358222 Bug fixes
794e4ce hi2
11d24e3 hi
bb6e1e9 +last
04a920c Post
➜ jettcom git:(master) ✗ git checkout 11d24e3
M Simple/Gemfile
M Simple/Gemfile.lock
M Simple/app/views/estados/index.html.erb
M Simple/config/application.rb
M Simple/config/environments/development.rb
Note: checking out '11d24e3'.

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 performing 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 11d24e3... hi fatal: ref HEAD is not a symbolic ref
➜ jettcom ✗

In the video the teacher did it and this didn't happen.

It would appear that you've checked out a commit state rather than checking out a branch. You're not really on a branch at all. I would recommend doing "git checkout master" to get back onto your master branch and then run "git branch" to see which branches are available to checkout. You'll probably want to double check your files and make sure your git status is where you intend to be before commiting again. It's easy to get lost at first.

nits ain
nits ain
682 Points

I getting this output on entering the below command: git diff 1221f 7ad76 fatal: ambiguous argument '1221f':unknown revision or path not in the working trend. Use "--" to separate paths from revisions.

Please explain the err.