• Skip to main content
  • Skip to primary sidebar

Code Inherit

Simple Programming Code Examples

Create a branch of specific commit in git or git hub

15th January 2024 by Site Admin Leave a Comment

To create a branch at a specific commit in Git or GitHub, you can use the following steps:

Git Command Line:

  1. Open your terminal or command prompt.
  2. Navigate to your Git repository using the cd command:

cd /path/to/your/repository

Find the commit hash you want to create a branch from using:

git log

  1. Copy the commit hash.
  2. Create a new branch at that commit using:

git branch new-branch-name commit-hash

  1. Replace new-branch-name with the desired branch name and commit-hash with the copied commit hash.
  2. Switch to the newly created branch:

git checkout new-branch-name

Or you can use a single command to create and switch to the new branch:

git checkout -b new-branch-name commit-hash

GitHub Web Interface:

  1. Go to the GitHub repository in your web browser.
  2. Click on the “Code” tab.
  3. Click on the “Branch: main” (or whatever your default branch is) dropdown.
  4. Type the name for your new branch in the “Find or create a branch” field.
  5. Click on the “Create branch: new-branch-name from ‘commit-hash'” button.

GitHub Command Line:

  1. Open your terminal.
  2. Clone the repository (if you haven’t already):

git clone https://github.com/your-username/your-repository.git

Navigate to the repository:

cd your-repository

Find the commit hash you want to create a branch from using:

git log

  1. Copy the commit hash.
  2. Create a new branch at that commit using:

git checkout -b new-branch-name commit-hash

  1. Replace new-branch-name with the desired branch name and commit-hash with the copied commit hash.
  2. Push the new branch to GitHub:

git push origin new-branch-name

These steps should help you create a branch at a specific commit either using the command line or GitHub’s web interface.

Filed Under: Uncategorised

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Bijoy Converter
  • How to amend previous commit with current changes in git and github?
  • How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?
  • Create a shell script to switch 7.4 to 8.1 and vice versa
  • How to reflect PHP8.1 to Apache in MacOS?

Recent Comments

    Archives

    • October 2025
    • September 2024
    • January 2024
    • July 2023
    • October 2021
    • September 2021
    • February 2021
    • January 2021
    • October 2020
    • September 2020
    • August 2020
    • May 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • May 2019

    Categories

    • Couchbase
    • Cron Job
    • dhis2
    • Linux, MySQL
    • MySQL
    • Oracle
    • Oracle Client
    • PHP
    • SSL
    • Subdomain
    • Uncategorised
    • Wordpress
    • WP
    • Zip

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in