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 trialhuckleberry
14,636 Pointsgit checkout command - What the Tommy says vs what the console tells you.
Hello,
In the video, Tommy, when referring to the "detached HEAD state" message that you get after you check something out, says "This isn't actually a scary situation. This is just gits way of letting you know that you've checked out an older version of your code and that if you try to make any changes right now, things could get weird"
Yet the console message says "You can look around, make experimental changes and commit them... "
So he's saying things could get weird, which I interpret as "go bad" and the console is telling you that "sure, go ahead, muck about... you can even commit it!"
Which is it?
I realize that right now, things are just "theoretical" and I haven't really experienced the whole git thing in an actual setting while working on a project so I more than likely don't truly "get it" right now... but can someone explain it here?
What would happen if you went in and changed a file here? without committing... with committing if you commit, does it replace that version? Or does it make like... a sub version?
I haven't gotten to branching yet so if it involves branching or if this will be further explained later, just let me know.
Thanks!
Huck -
1 Answer
Samuel Webb
25,370 PointsThe 'git checkout' command is what you'll be using to switch to different branches or switch from a branch back to master. The problems occur when you're not sure what branch you're on and you start committing and pushing stuff up to GitHub. In reality, if you need to pull in the most up-to-date code from GitHub, you'd be using 'git pull' for that. Also, I'd suggest mucking around with Git and GitHub as much as possible because it's knowledge that seems to be required and the only way to truly get comfortable with it is to play around. The whole point of it is that you can always go back to an old version of your code so if you commit often, you'll never truly lose anything you've done.
huckleberry
14,636 Pointshuckleberry
14,636 PointsOk so long story short is I'll understand it more when I get to the branches which I'm doing today. Gotcha lol.
I have installed and git and setup github and I have been mucking about in the git console on my computer but not dealing with an actual project. Right now I've simply been creating directories, changing directories, removing and renaming, creating files, listing out files, creating repositories, adding and committing dummy files, yadda yadda... you know, drilling the fundamentals.
Prior to the desire for learning git I had never used or even learned anything about the console because, heh, windows. So I took the console foundations and now I have an environment to use that knowledge in but it obviously takes some getting used to coming from a strict GUI mindset. Just thinking in terms of paths vs visual tree structures and mentally knowing where you are and how to get back to where you want to be and vice versa is the whole hurdle in a nutshell. So that's where I'm at now and to be honest I feel like I should take a day and go in and rename all my directories and files because most of them have spaces and capitals. I never had to think about naming conventions that are useful for console navigation but now I find myself constantly frustrated with case sensitivity and having to wrap file and directory names in quotes lol.
anyway, I'll get to the actual relevant utilization soon enough because I do have a project that I'm working on and that's the very reason I decided to buckle down and finally learn git. In the meantime I'll just keep what you said in mind and get moving on the branching part of the course.
Thanks!
Huck -