Git — HEAD

Git, GitHub huh!!. You you know, but let me first break down what git is and how it differs from git hub to that person who is hearing about them for the first time before i proceed to my main aim which is Git-Head. Git is a continuous integration tool that serves to ease the role of version control for developers. Git is installed on the remote computer to help keep track of the local files on one’s computer, whereas GitHub is a social site that holds published files for the world to access depending on the publisher’s settings.

Importance of git:

Ever been in a situation where you;

· Made a change to code, realised it was a mistake and wanted to revert back?

· Lost code or had a backup that was too old?

· Had to maintain multiple versions of a product?

· Wanted to see the difference between two (or more) versions of your code?

· Wanted to prove that a particular change broke or fixed a piece of code?

· Wanted to review the history of some code?

· Wanted to submit a change to someone’s else code?

· Wanted to share your code, or let other people work on your code?

· Wanted to see how much work is being done, and where, when and by whom?

· Wanted to experiment with a new feature without interfering with working code?

Why it’s useful:

You don’t lose anything. I never again commented out code. I simply delete it. It doesn’t clutter my screen, and it isn’t lost. I can recover it by checking out an old commit.

You can experiment at will. If it doesn’t solve the problem, revert it.

You can look at previous versions of the code to find out when and where bugs were introduced. git bisect is great in that regard.

More “advanced” features like branching and merging let you have multiple parallel lines of development. You can work in two simultaneous features without interference and switch back and forth without much hassle.

You can see “what changed”.

Git - Head

HEAD is a reference to the last commit in the currently checked-out branch. Generally speaking, HEAD is just a convenient name to mean “what you have checked out” and you don’t really have to worry much about it. Just be aware of what you have checked out, and remember that you probably don’t want to commit if you’re not on a branch (detached HEAD state) unless you know what you’re doing (e.g. are in an interactive re base). The branch itself is a reference to the commit at the tip of the branch.

You can think of the HEAD as the “current branch”. When you switch branches with git checkout, the HEAD revision changes to point to the tip of the new branch.

You can see what HEAD points to by doing: git/HEAD

It is possible for HEAD to refer to a specific revision that is not associated with a branch name. This situation is called a detached HEAD.

Note this difference: a “head” (lowercase) refers to any one of the named heads in the repository; “HEAD” (uppercase) refers exclusively to the currently active head. This distinction is used frequently in Git documentation.

Importance of the HEAD

The HEAD is important as it helps you keep track of commits. You could return to a previous commit, reattach a detached HEAD, do a soft reset and a hard reset.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.