Restoring a lost svn history for a git project











up vote
1
down vote

favorite












I have a project, that was migrated from SVN to git some time ago.



WELL. Not really migrated. The last SVN revision was copied into the initial git commit. So basically all SVN history was squashed into the first git commit.



Many commits have now been added to the git repository.



Is there a way to way to rebase the new git commits onto a properly converted git repo? So we have the full history again?



Edit:



I now have two git branches, one with all the old history (old), another with all the new history (new). There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I have a project, that was migrated from SVN to git some time ago.



    WELL. Not really migrated. The last SVN revision was copied into the initial git commit. So basically all SVN history was squashed into the first git commit.



    Many commits have now been added to the git repository.



    Is there a way to way to rebase the new git commits onto a properly converted git repo? So we have the full history again?



    Edit:



    I now have two git branches, one with all the old history (old), another with all the new history (new). There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a project, that was migrated from SVN to git some time ago.



      WELL. Not really migrated. The last SVN revision was copied into the initial git commit. So basically all SVN history was squashed into the first git commit.



      Many commits have now been added to the git repository.



      Is there a way to way to rebase the new git commits onto a properly converted git repo? So we have the full history again?



      Edit:



      I now have two git branches, one with all the old history (old), another with all the new history (new). There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?










      share|improve this question















      I have a project, that was migrated from SVN to git some time ago.



      WELL. Not really migrated. The last SVN revision was copied into the initial git commit. So basically all SVN history was squashed into the first git commit.



      Many commits have now been added to the git repository.



      Is there a way to way to rebase the new git commits onto a properly converted git repo? So we have the full history again?



      Edit:



      I now have two git branches, one with all the old history (old), another with all the new history (new). There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?







      git svn git-svn






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 10 hours ago

























      asked yesterday









      MaxNoe

      7,66622429




      7,66622429
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          With a little work, sure. First, migrate correctly the svn repo into a git repo. Then add the git repo that you created from svn before (bad-remote, from now on) as a remote. When you fetch from it, you will be able to see the remote branches from bad-remote. Then rebase (or cherry-pick, whavever you think will be fine) the work that you did on bad-remote on top of the new svn branches on this repo.



          git rebase --onto svn-full-history svn-short-history-first-revision-id svn-short-with-git-only-commits


          That should apply all the git-only changes onto the full svn branch.






          share|improve this answer























          • I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
            – MaxNoe
            10 hours ago












          • I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
            – eftshift0
            9 hours ago










          • The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
            – eftshift0
            9 hours ago












          • This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
            – MaxNoe
            9 hours ago










          • You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
            – eftshift0
            9 hours ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265684%2frestoring-a-lost-svn-history-for-a-git-project%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          With a little work, sure. First, migrate correctly the svn repo into a git repo. Then add the git repo that you created from svn before (bad-remote, from now on) as a remote. When you fetch from it, you will be able to see the remote branches from bad-remote. Then rebase (or cherry-pick, whavever you think will be fine) the work that you did on bad-remote on top of the new svn branches on this repo.



          git rebase --onto svn-full-history svn-short-history-first-revision-id svn-short-with-git-only-commits


          That should apply all the git-only changes onto the full svn branch.






          share|improve this answer























          • I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
            – MaxNoe
            10 hours ago












          • I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
            – eftshift0
            9 hours ago










          • The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
            – eftshift0
            9 hours ago












          • This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
            – MaxNoe
            9 hours ago










          • You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
            – eftshift0
            9 hours ago















          up vote
          1
          down vote













          With a little work, sure. First, migrate correctly the svn repo into a git repo. Then add the git repo that you created from svn before (bad-remote, from now on) as a remote. When you fetch from it, you will be able to see the remote branches from bad-remote. Then rebase (or cherry-pick, whavever you think will be fine) the work that you did on bad-remote on top of the new svn branches on this repo.



          git rebase --onto svn-full-history svn-short-history-first-revision-id svn-short-with-git-only-commits


          That should apply all the git-only changes onto the full svn branch.






          share|improve this answer























          • I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
            – MaxNoe
            10 hours ago












          • I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
            – eftshift0
            9 hours ago










          • The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
            – eftshift0
            9 hours ago












          • This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
            – MaxNoe
            9 hours ago










          • You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
            – eftshift0
            9 hours ago













          up vote
          1
          down vote










          up vote
          1
          down vote









          With a little work, sure. First, migrate correctly the svn repo into a git repo. Then add the git repo that you created from svn before (bad-remote, from now on) as a remote. When you fetch from it, you will be able to see the remote branches from bad-remote. Then rebase (or cherry-pick, whavever you think will be fine) the work that you did on bad-remote on top of the new svn branches on this repo.



          git rebase --onto svn-full-history svn-short-history-first-revision-id svn-short-with-git-only-commits


          That should apply all the git-only changes onto the full svn branch.






          share|improve this answer














          With a little work, sure. First, migrate correctly the svn repo into a git repo. Then add the git repo that you created from svn before (bad-remote, from now on) as a remote. When you fetch from it, you will be able to see the remote branches from bad-remote. Then rebase (or cherry-pick, whavever you think will be fine) the work that you did on bad-remote on top of the new svn branches on this repo.



          git rebase --onto svn-full-history svn-short-history-first-revision-id svn-short-with-git-only-commits


          That should apply all the git-only changes onto the full svn branch.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered yesterday









          eftshift0

          4,019817




          4,019817












          • I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
            – MaxNoe
            10 hours ago












          • I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
            – eftshift0
            9 hours ago










          • The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
            – eftshift0
            9 hours ago












          • This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
            – MaxNoe
            9 hours ago










          • You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
            – eftshift0
            9 hours ago


















          • I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
            – MaxNoe
            10 hours ago












          • I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
            – eftshift0
            9 hours ago










          • The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
            – eftshift0
            9 hours ago












          • This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
            – MaxNoe
            9 hours ago










          • You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
            – eftshift0
            9 hours ago
















          I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
          – MaxNoe
          10 hours ago






          I now have two git branches, one with all the old history, another with all the new history. There is no diff between the last commit of old and the first commit of new. How do I merge those histories into one?
          – MaxNoe
          10 hours ago














          I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
          – eftshift0
          9 hours ago




          I'm not sure I quite understood. If I'm not mistaken what you mean is that you have fetched the full history of the svn branch (only working on a single svn branch, right?).. which I would assume I meant to call new and then you can also see on this repo the git repository with the old sv branch plus a lot of work done on git and not on svn, which I would assume you would call old. You have compared the first revision of old (which is the last revision of the project taken from svn) with the last revision of new (which is the branch with the full story) and they are both the same
          – eftshift0
          9 hours ago












          The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
          – eftshift0
          9 hours ago






          The next step would then be to ask git to put the git-only history of the old repo onto the new svn branch, right? I'll add the recipe on my original answer
          – eftshift0
          9 hours ago














          This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
          – MaxNoe
          9 hours ago




          This would work, if the new git history is just linear. However there are tons of merges and resolved conflicts git know wants to have resolved again
          – MaxNoe
          9 hours ago












          You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
          – eftshift0
          9 hours ago




          You could try to replicate the merges with --rebase-merges or --preserve-merges. git help rebase will provide you will all the gory details (including a full section on rebasing merges).
          – eftshift0
          9 hours ago


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265684%2frestoring-a-lost-svn-history-for-a-git-project%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents