Tags, Upstream, and detached HEAD#
Git tags from upstream#
How do I sync tags to a forked github repo?
git remote add upstream
if upstream is not defined in .git/configgit fetch --tags upstream
git tag
now tags from upstream listed
Push single tag#
git push origin tag
HEAD vs detached HEAD#
Git has two modes HEAD:
- "on a branch": the special name HEAD, in all uppercase like this,1 contains the name of a branch.
- "detached HEAD": the special name HEAD contains the raw hash ID of a commit.
Given that the second mode is called detached HEAD mode, I like to call the first mode attached HEAD mode.
While you can use Git in the second mode as much as you like, the way most people prefer to use Git is in the first mode, because it's usually more useful. The detached HEAD mode exists for two primary reasons:
- to let you view any particularly interesting commit, by running git checkout hash-id or git checkout tag-name for instance; or
- to handle an in-progress git rebase that requires human assistance.
To force detached mode when using a branch name, you can (as you noted at one point) use git checkout --detach name
—but unless you're implementing a new Git command, or something along these lines, that's not a normal thing to do.
Key points:
- Detached HEAD Mode Usage: Not a common practice unless implementing a new Git command.
- Attached HEAD Mode Advantage: Automatically remembers the hash ID of the new commit, making it easier to revisit later.
- Commit Identification: Commits are identified by unique hash IDs, which are stored in the parent commit for future reference.
- Branch Growth Mechanism: Branches grow by creating new commits that point to the previous commit, updating the branch name to reflect the latest commit.
- Detached HEAD Mode: Using a commit hash directly puts Git in detached HEAD mode, allowing access to specific commits but limiting the ability to add new commits.
- Attached HEAD Mode: Working on a branch name uses attached HEAD mode, enabling the creation of new commits and maintaining a reference to the latest commit.