Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4536236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:30:31+00:00 2026-05-21T14:30:31+00:00

I have a small project I was working on without any kind of version

  • 0

I have a small project I was working on without any kind of version control software, and I ended up with three different versions of the same script, where each one does something slightly different from the others. I initialized a git repo with one of the versions, and I’d really like to commit each of the other two without parents. That way, I can merge the differences as though each of the three versions of the script were the tips of different branches.

I’m not even sure whether this is necessarily a sane or reasonable way to go about solving this problem… Any advice on how to do things this way, or advice on a better way to handle this situation would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:30:32+00:00Added an answer on May 21, 2026 at 2:30 pm

    From my comment:

    Why don’t you create two branches and add the two other versions to them and then work on the branches?

    Which I think would agree with ctcherry’s answer as well.


    But if you really do want to create a completely different “branch” that is unrelated to master, then you can do it with git checkout --orphan. The manual for git checkout describes to work of the option --orphan:

    Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.

    You might use it like this:

    git checkout --orphan version2
    git rm -rf .
    <add version2 script>
    git add your files
    git commit -m 'Initial commit for version 2'
    

    If your Git is older than 1.7.2 (when git checkout --orphan was introduced), then you can use the alternate command sequence from “Creating New Empty Branches” in the Git Community Book:

    Ocasionally, you may want to keep branches in your repository that do not share an ancestor with your normal code. Some examples of this might be generated documentation or something along those lines. If you want to create a new branch head that does not use your current codebase as a parent, you can create an empty branch like this:

    git symbolic-ref HEAD refs/heads/newbranch 
    rm .git/index 
    git clean -fdx 
    <do work> 
    git add your files 
    git commit -m 'Initial commit'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been running cocos2dx version 1.0.1-x-0.11.0 till now and have a small project working
I have a small project that I will be working on shortly that collects
I'm new to objective C and currently working on a small project. I have
I'm working on a small uni project where I have a program for a
I have a small software project with a couple clients. What I'm looking for
I'm working on a project where I have to add a small preview pane
I have a small project that I'm working with inheritance and polymorphism. I have
I have this small project I have been working on. I have a MySQL
Have been working on a small project, and have gotten stuck at a part
i'm working on a small project that might have an additional coder at some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.