Create branch from a particular commit: BitBucket

Sometimes we may need to create a branch from a particular commit. Many people know how to create a branch from another branch. Some people may know how to create new branch from a particular commit using Git. But in Bitbucket UI, there is not direct provision for creating new branch from a particular commit of another branch.
For example if a branch contains 10 commits and we require to create a branch up to 5th commit of that branch. We don't want remaining 5 commits in the new branch. In this case many people will create new branch from the old branch and revert the commits which are not required. Instead of thise large process we can  branch from a particular commit of another branch in BitBucket UI using Tags concept. Following steps will illustrate it.


Open the commit and create a tag for it
Suppose I have 3 commits and I want to create repository from the second commit

Open the commit and add tag (click on the + symbol after Tag icon on the right side)


Once added the tag, Click on Branches -> Create Branch -> Select the tag in the "From Branch" column.

Note: Sometimes the tag will not be displayed in the below list if the Branches and Tags list is very lengthy. In that case type the first characters of the tag name will filter it.

Give the name of the new branch and click on "Create" button. It will create new branch and the new branch will have the commits up to the selected commit only.

Happy Coding!😊


    Blogger Comment
    Facebook Comment


Post a Comment