Git

Detached HEAD in Git

Detached HEAD Before everything, let’s have a look at some stuff. Everything in Git is about commits, and many git commands accept commits as a parameter, i.e.

We have to understand how to reference commits. Hash The SHA-1 hash of a commit is the most straightforward method to refer to it. In the

Detached HEAD in Git Read More »

Mastering git, Part 11, View git history (commit log) of specific lines of code in a file

git blame The git blame command is used to know who/which commit is responsible for the latest changes made to a file. The author/commit of each line can also been seen. git blame does not show the per-line modifications history in the chronological sense. It only shows who was the last person to have changed …

Mastering git, Part 11, View git history (commit log) of specific lines of code in a file Read More »

Mastering git, Part 5, git cherry-pick

To illustrate what is cherry-pick let’s imagine  the following situation: you and another developer start working on project, you will both make some changes, but after a while the other developer find a bug in the code and you are interested in to only apply that hot-fix without taking other changes from another developer, in this situation you should …

Mastering git, Part 5, git cherry-pick Read More »

Mastering git, Part 4, git merge, git diff with GUI tools

Before following this post, make sure you have already set up everything from my other post regarding the configuration of git environment. Diff Diff command will allow you to compare two different commits, let’s set up a repository:

Now in the second repository, we make some changes:

now let’s back to the first repository and see the …

Mastering git, Part 4, git merge, git diff with GUI tools Read More »

Mastering git, Part 3 (Undo local changes, git revert, git reset, git amend and git clean)

1. Checkout The git checkout  moves the HEAD ref pointer to a specified commit. To demonstrate this, consider the following example:

Now you can change the HEAD with:

or

you can find all commits again by:

For instance:

1.2 Detached HEAD Any checkout of a commit that is not …

Mastering git, Part 3 (Undo local changes, git revert, git reset, git amend and git clean) Read More »