Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How to Create Empty Branch in Git Repository

    How to Create Empty Branch in Git Repository

    By RahulJune 4, 20221 Min Read

    I have an application code maintained in the Github repository. Now our requirement is to create the documentation for that application and save them under a separate branch in the same repository. I simply tried to create a new branch but it linked to the main branch. After googling it, I found an option --orphan to create branch with no parents.

    Advertisement

    This tutorial will help you to create a new empty branch in the Git repository.

    Git Create Empty Branch

    We can use --orphan command line option to create a new branch with no parents.

    git checkout --orphan new-empty-branch 
    

    The above command will create a new branch with no parents. Now, you can delete files from the working directory, so they don’t commit to a new branch.

    git rm -rf . 
    

    Now, you can add new files to this new branch, commit and push them up to the remote git repository.

    branch git
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Split Large Archives in Linux using the Command Line

    System.out.println() Method in Java: A Beginner’s Guide

    sleep Command in Linux with Examples

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.