1

At work we moved from SVN to BitBucket a few weeks back. At the beginning, some colleagues started to split code from what used to be the main single SVN trunk into repositories by just moving the files around without taking care of the commit history. Now, I am doing this properly by following the procedure outlined in link #2 below.

For those cases which were done in the past, I would like to dig the history for those folders from the original repository where the main SVN trunk ended up and apply it to the repositories where the code was moved to. Is there an easy way to do it? Bear in mind we're quite new to GIT and BitBucket so solutions that may appear obvious to you will not be so straightforward to us...

I am thinking about generating patches from the old repository and applying them in the new one but since the folders are not there anymore, should I go back to the commit where the folders were deleted? If so, how?

Thanks a lot in advance!

For clarification, what happened is (no branching at all!):

  • Clone Repo A.
  • Create Repo B and clone.
  • Move folder XYZ between the local folders.
  • Commit deletion of files on Repo A.
  • Add files in Repo B.
  • Commit addition of files on Repo B.
  • Push both repos to master on remote.

Note: I have already checked the following two threads and they do not do exactly what I want. In fact, I have used the second one to move folders into independent repositories successfully afterwards.

Link #1 - Git: Copy history of file from one repository to another

Link #2 - How to move files from one git repo to another (not a clone), preserving history

  • Is there some reason you can't fork Repo A? – Jim Redmond Mar 05 '19 at 19:29
  • Hi @JimRedmond. As you can imagine, we are not well versed in GIT or BitBucket yet. We thought the best way to have a cleaner structure was to split the code in different repositories as it also belongs to different applications altogether (so it really does not make sense for the code to be in the same repository from our point of view). – Xavi Gutierrez Mar 06 '19 at 12:59
  • So, after some investigation of my own, I am going to try the following since there seems to be no input from anyone... 1: Clone the main repository 2: Go back to the commit just before the code was split from the main repository. 3: Run the procedure I got in Link #2 above to split the folders as if they were there. 4: Clone the new repository 5: Pull the old folder with all the history into the new repository (missing all the history) 6: See what happens... if all goes well, git push to remote from the new repository. – Xavi Gutierrez Mar 19 '19 at 17:46
  • Does this answer your question? [git move directory to another repository while keeping the history](https://stackoverflow.com/questions/41811986/git-move-directory-to-another-repository-while-keeping-the-history) – Hugh Perkins Nov 29 '21 at 14:58

0 Answers0