For example, if you want to see which commit the branch
mybranch references, you can run
$ git rev-parse mybranch
$ cat .git/refs/heads/mybranch
git log, is there a single file git looks at to find all the commits for that branch?
git log figures out the history by taking the commit the
branch references and looking at that commit's parent(s) / grandparents
etc. A commit's parents can't change, so the history is always the
HEAD is a reference to the current commit or branch you have
checked out! Usually it's a reference to a branch. You can see what it
is by running
"You are in 'detached HEAD' state".
HEADpoints to a commit, not a branch
HEAD points to a commit, no branch gets updated when you make new commits.
git warns you about this because if commits aren't on a branch, it's hard to find them later.
git commit, does it change which commit your current branch points to?
git commit creates a new commit and then updates the current branch to point at the new commit.
you can view it with
$ git reflog BRANCHNAME
so if you want to go back to what you had on that branch last Tuesday, you can!
creating a new branch just creates 2 small files: a reference to the current commit and a history of what you've done with the branch (the reflog).
you can make a branch point at a different commit with either
banana), do both versions of the branch always point at the same commit?
branch names are local to a repository, and they don't get automatically synced in any way.
... and you're done! To get the most out of this set of questions, consider taking a minute to write down (in your own words) one or two things you learned!
If you want, you can write down what you learned in this box and anonymously send it to me. Hearing what people are learning helps me build better questions in the future :)