Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a branch from Git commit ID within Github web UI

Tags:

git

github

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..

enter image description here

like image 612
vinWin Avatar asked Jan 31 '20 13:01

vinWin


People also ask

Can we create branch from commit ID in git?

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).

How do you create a branch in git from a 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.


1 Answers

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:

enter image description here

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:

enter image description here

Then click on the "Create branch: ..." link at the bottom of this dropdown, and a new branch should be created.

like image 146
Lasse V. Karlsen Avatar answered Nov 13 '22 16:11

Lasse V. Karlsen