Skip to main content.

Basic git Commands


After installation of the "git-core" package, you will find the git related documentation in the /usr/share/doc/git-core-<version>/ directory on your system. Make sure to read at least the "tutorial.txt" file!


"internal branches":
= heads.
The content of the ".git/refs/heads/foo" file is the SHA1 object name of the commit that is at the top of "foo" branch. When your ".git/HEAD" symlink points at "refs/heads/bar", your working tree is said to be on the "bar" branch.

"external branches":
= other repositories
= sometimes used to make clear that it's a branch internal to one repo

What happens normally (at least for core git) is that the ".git/branches" directory contains external sources for the branches (for example, a "git clone" will fill in the "origin" source, while I often have a ".git/branches/parent" in my tree because. That is just a pointer to where the external branch exists.)

Then, when you do something like

   git fetch parent
it will look up the source of "parent" by looking in the ".git/branches/parent" file, and update the ".git/refs/heads/parent" branch appropriately from that external branch.

So in this example the parent "head" ("local branch") points to the actual commit we have, while the ".git/branches/parent" thing points to what external branch it came from.

But yes, you can mess this up if you want to. If you have the same "external branch" name that you use for an "internal branch", you deserve all the confusion you get wink

Working with branches