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 6899725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:27:28+00:00 2026-05-27T07:27:28+00:00

I have a tree that looks like the following B / \ A D

  • 0

I have a tree that looks like the following

  B
 / \
A   D
 \ /
  C

B and C don’t conflict. What I want is it to show in my history as A-B-C-D.

How can I do this in git? I’ve searched but I can’t find an answer I feel applies. I’m concerned to make a change because I don’t want to make things worse and I don’t know how I would undo it (is there a way to undo the last git command in git?)

  • 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-27T07:27:29+00:00Added an answer on May 27, 2026 at 7:27 am

    If you want to test things out, simply clone your repository and play in the clone.

    $ git clone your_repo test_repo
    $ cd test_repo
    

    In your case, D should just be a merge commit, which doesn’t contain much if B and C don’t conflict. So a simple rebase will work

    $ git rebase branch_of_B branch_of_C
    

    Try this in an empty repository:

    echo A > file1
    git add file1
    git commit -m A
    git checkout -b B
    echo B > file2
    git add file2
    git commit -m B
    git checkout master
    git checkout -b C
    echo C > file3
    git add file3
    git commit -m C
    git checkout -b merge_branch
    git merge B
    echo D > file4
    git add file4
    git commit -m D
    

    You now have this (run gitk --all):

       B
      / \
     A   M - D
      \ /
       C
    

    and you’re on D. You can issue

    $ git rebase B
    First, rewinding head to replay your work on top of it...
    Applying: C
    Applying: D
    

    And you’re left with:

    A - B - C' - D'
     \
      C
    

    with C' and D' identical to C and D in terms of “contents”. If you want to clean up, you can remove branch C in this example, but you’ll have to force it since that will make the original C commit dangle.

    $ git branch -D C
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a git tree that looks like the following: Because of the review
I am trying to have a tree display custom data that looks like this.
I have a binary tree in unordered list that looks like this: <ul> <li>1
I have a tree expression that looks like this: .Block( System.Object $instance, MyType2 $result)
I want to have a comments section in my app that looks like this:
I have an object tree that looks something like Ball / \ LegalBall IllegalBall
I have a query with a self join that looks like this, select t1.
I have an xml file that looks like the following <siteinfo> ... </siteinfo> <page>
I am using the Javascript InfoVis SpaceTree. I have a tree that looks like
I have a table that looks like this: category category_id name category_seo_friendly_url left_id right_id

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.