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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:09:43+00:00 2026-05-12T15:09:43+00:00

I have started using Git in the middle of my project, where the first

  • 0

I have started using Git in the middle of my project, where the first two commits are just some initial settings (.gitignore and .gitattributes), and the third commit M2 adds the content of the SVN trunk:

I1 -- I2 -- M2 -- N -- .. -- Z

I have imported the SVN history in a branch named svn, where M1 is the SVN trunk (with the same content as M2, except .gitignore and .gitattributes):

A -- B -- ... -- K -- L -- M1

Q: What is the best approach in merging both branches?

I could merge M1 and M2 into M3, and then rebase, but I don’t know how to delete the I1 and I2 commits and if I can safely remove the M3 commit (I have found some advices to preserve the merge commits, but in this case M3 it’s not necessary anymore).

A -- B -- ... -- K -- L -- M1
                             \
                              M3 -- N' -- .. -- Z'
                             /
               I1 -- I2 -- M2 -- N -- .. -- Z

Another way would be to cherry-pick the N .. Z commits into svn branch by hand, but I would like to avoid this approach.

The most elegant solution would be to rebase the changes introduced by N .. Z commits on top of svn branch, but I didn’t found yet the required syntax for two branches without a common ancestor.

  • 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-12T15:09:44+00:00Added an answer on May 12, 2026 at 3:09 pm

    Disclaimer: I’ve only used “graft points” myself once in a toy repository. But it is an obscure feature which you may not have heard of, and which _may_ be helpful in your situation.

    You could use “graft points” to fake the ancestry information. See, e.g., What are .git/info/grafts for? or proceed immediately to the git wiki entry on graft points.

    In essence, you would create a file .git/info/grafts that tricks git into thinking that commit M1 is an ancestor of commit M2:

    $ cat .git/info/grafts
    <your M2 commit hash> <your M1 commit hash>
    

    Subsequently, it would look like M2 was an empty commit that just merged I2 and M1 into a common tree.

    The major downside: the graft point is not committed; therefore, it is not checked out, but needs to be added to each local working copy of the repository manually.



    Update: use git replace --graft instead.

    Graft points, as described above, have been superseded. Run

    git replace --graft <your M2 commit hash> <your M1 commit hash>
    

    to create the graft. This is stored in .git/refs/replace/. Although git does not fetch, or push, these refs by default, they can be synchronized between repositories using:

    git push origin 'refs/replace/*'
    git fetch origin 'refs/replace/*:refs/replace/*'
    

    (StackOverflow: How to push ‘refs/replace’ without pushing any other refs in git?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have just started using a git account of our Django website project so
I've just started using Git and I love it, but I have had an
I have just started using git. Rebase is great stuff. I should have used
I have just started writing a web application. I am using GIT for version
I recently started using git and have a question. I have two branches of
I have started using PDO in php for the first time. Here is my
I have started using Linq to SQL for a project im working on and
I'm trying to get started using git, but I'm having some troubles right away.
I have just started a new git repository. I followed the directions on github,
I've recently started using Git and am having trouble with just one thing. How

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.