Hello, how can i create a branch from an old commit?
thanks
Unfortunately there is no way in the UI to create a branch from an old commit.
You can create a branch from a commit in git using your terminal and the command:
git branch <branchname> <commitHash>
Unfortunately there is no way in the UI to create a branch from an old commit.
You can create a branch from a commit in git using your terminal and the command:
git branch <branchname> <commitHash>
There is a way. It's a little awkward, but it works.
1. Click on the commit in the web UI.
2. Click on the "[+]" button next to the word "No Tags" (far right middle of screen). (Or if the commit already has a tag, just use that to create the branch.)
3. Create a temporary tag against the commit. Click the "Create Tag" button to save your tag.
4. Go to the "Create Branch" dialog. Find your tag. Use that!
5. Go back to the commit from step 1. and delete the tag you created.
By cosmic coincidence, this works on both Bitbucket Cloud (bitbucket.org) AND Bitbucket Server! Despite these two Bitbucket implementations being very different, the UI for doing this is pretty much the same in both.
- Sylvie @ Bit-Booster
(We maintain 3 add-ons for Bitbucket Server: Rebase Squash Amend, Git Graph for JIRA, and Control Freak).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I actually hadn't considered doing that. It's certainly not our recommended way of creating a branch from a commit, but you're right - it works!
If someone wants to create branches often then they are probably going to have a clone handy - in which case it would be easier to just do it locally and push the ref. But if this is a one-off, and the person creating the branch doesn't have a local clone, then perhaps doing it in this round-about way would be quicker!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kristy
Even when you have a local clone, some repositories will let you only push commits that are signed by you. (I.e. you won't be allowed to push commits stored in your local clone that are signed by your colleague.)
Cheers
Jarda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can follow steps 1-4, but how do I perform step 5 "Go back to the commit from step 1. and delete the tag you created"? A Bitbucket Cloud commit lists all the tags associated with the commit, but AFAICT it doesn't provide an option to delete a tag.
Either I must leave the temporary tag or use the terminal to delete the tag. And if using the terminal, I might as well use it to directly create the tag.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I like your solution, it sounds straight forward.
In the "From branch" selection at the bottom, I can see the selection "Tag" but it just shows two tags and I can not select any other tags.
Does anybody have the same issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, it was an user issue. I did not know, that you just can start typing the tag name in the dropdown "From branch".
Now i can select the correct tag.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The command below, run from the local repository, worked for me. Then, I could see the newly created branch via Bitbucket web GUI.
git push origin <sha1-of-commit>:refs/heads/<branch-name>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.