This deals : How do I create a new Git branch from an old commit? about creating new branch needed from command line on a repository based on commit-id
pretty much,
git checkout -b ini_commit_ref_branch cf05eed4fbd76e30615e3876ead9ddb7c5593cd8 # eg commit
git push --set-upstream origin ini_commit_ref_branch
But how to achieve same within Github WebUi - as option of creating remote branches we get only on existing branches not from commit hash. Do we have that feature within web-ui ?.
All we see are below icons when we traverse to history of commits against selected branch in repo..
It is worth noting that if you had checked out a commit using git checkout <SHA1> (and therefore you're on a detached HEAD ), you can create a branch at that commit by just using git branch <branchname> or git checkout -b <branchname> (no SHA1 argument required for the same commit).
In order to create a Git branch from a commit, use the “git checkout” command with the “-b” option and specify the branch name as well as the commit to create your branch from. Alternatively, you can use the “git branch” command with the branch name and the commit SHA for the new branch.
Here's how you do it.
First navigate to the commit in question, and then click on the <>
button next to the commit in your history. This will show the web interface for browsing that particular commits snapshot of the repository.
Then, you see a small button with the commit id, just above the contents, like this:
Then, click the down arrow on this button to show the dropdown. It looks like this one allows you to browse different branches in the repository but you can actually create a new one. Simply type in the name of the new branch in the search field:
Then click on the "Create branch: ..." link at the bottom of this dropdown, and a new branch should be created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With