Git branches contd…
-
The current DAG for REL_1.0 and REL_1.1

-
Now lets make a commit in REL_1.0

-
The changes which we have done in this commit (c070965) in REL_1.0 branch are also required on REL_1.1 branch
-
When you want a changes in specific commit or specific sequence of commits we can use git’s feature which we call as cherry-pick
-
Now lets move to REL_1.1 branch and execute the cherry-pick command

-
Now lets move to the master branch
-
We have observed that HEAD always points to branch which in turn points to latest commit on the branch

-
Now lets assume we checkout to a specific commit

-
Now the head points to a commit id rather than branch. This state is called as Detached HEAD.

-
Now lets create a branch from master called as REL_1.2 and make some commits there

-
Now lets assume there is an import change that is done on master

-
Now this change has to be present in REL_1.2 branch also. If the REL_1.2 branch was created after this important change then it would be smooth.

-
In Git this is possible to do with the help of rebase command. Rebase is git utilitiy that specializes in changing from one branch to other
- Current Situation

- With Rebase we can do the following. Checkout to REL_1.2 branch

- Current Situation
-
Lets make a commit

-
In this commit we have made a typo and we want to correct it. Mistake is done in latest commit message.
git commit --amend

- Now lets make three commits
- commit 1.2_4 => here we will make spelling mistake in commit message
- commit 1.2_5 => here we will make spelling mistake in code
- commit 1.2_6 => no errors

- If you want to rewrite history we can use interactive rebasing.
git rebase -i <HEAD~Position>. In this we need to go back 3 postions
git rebase -i HEAD~3

- We need to Reword commit 1.2_4 and ammend 1.2_5 and pick 1.2_6

- Now lets assume rather than having two commit 1.2_5 and 1.2_6 we would have it as one commit
git rebase -i HEAD~2

-
Current history

-
Now lets try to delete the commit for 1.2.4
git rebase -i HEAD~2
*
