and I wanted to come up with something like this:
AB—BC—CD—EF MASTER
Where SA is my new commit i.e to be inserted b/w commit BC & CD. Well, it isn’t actually an extreme or difficult case.It’s actually a very simple procedure to follow:
AB—BC—SA—CD—EF MASTER
Now your Repo will look like this :
$ git checkout master
$ git checkout -b temp BC
$ git add
$ git commit # your changes that will be SA
After this repository layout it’s rather simple to transform it into a single sequence of commits:
AB—BC—SA temp
\
CD—EF MASTER
You may get few conflicts that you need to resolve . Now you are all Done !!!
$ git rebase temp master
TAGGING COMMITS
You will notice that your SHA keys are modified and tag doesn't appear above commit BC to make sure your tags are in line follow the steps:
For each tag type the following command,
$ git tag -l #to list all your tags.
to see the details of the old commit. Make note of the subject line, date, and hash of the old commit.Page through git log looking for that subject line and date. Make note of the hash of the new commit when you find it.
$ git show TAG_NAME
Hope that you have not mistaken one commit for another with a similar subject line and date.Thanks to Santosh Mohanty for writing this post .
$ git tag --force TAG_NAME NEW_COMMIT_HASH #to update the tag.
