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 trialChristopher Borchert
14,814 PointsDiscrepancy between the video and the challenge (HEAD vs master), which should I use?
In the video, the instructor said that git checkout master would return us to the most recent commit, but the challenge had us use git checkout HEAD. Is this something I should commit to memory? When do I use (if ever) get checkout HEAD?
1 Answer
Ethan Lowry
Courses Plus Student 7,323 PointsHEAD refers to the most recent commit of whatever branch you're currently on. So if you already have the master branch checked out, then 'git checkout master' and 'git checkout HEAD' will basically do the exact same thing, as you suspected. Just remember that when you're on a branch other than master, then 'git checkout master' will bring you back on to the master branch again.
Using 'checkout HEAD' might be handy to remember because it can be used in a variety of different ways, for example the following will check out the code 2 commits prior to HEAD:
git checkout HEAD~2
Hope that helps.
Matthew Newman
8,741 PointsMatthew Newman
8,741 PointsNice explanation! I was confused about master and head as well. Now i know :)