I have been working a branch created long back in a repository. This has grown so big that it may never get merged to the trunk. For better maintenance I want to covert this branch to a new repository but carrying the history so far.
Please advice how this could be achieved using Source Tree or even git command line.
Thanks in advance
The suggestion didn't work out.
However I figured out a windy route to transfer the branch. This work fine for me on Windows (used Source tree and TortoiseGit to simplify some of the actions but given the equivalent commands here); should be ok on linux too. Good luck.
AIM: Create a new repo called NewRepo from the branch MyRepo/MyBranch
1. Clone the work branch (e.g., MyBranch) from the work repo (MyRepo) to the local drive (c:\MyBranch)
2. Create an empty repo (e.g. NewRepo) in Bitbucket
3. In c:\MyBranch, reinitialise the git repo with the command: "git init"
4. In c:\MyBranch, change its remote URL to that of NewRepo with the command: "git remote set-url origin https://ACCOUNT_NAME@bitbucket.org/WORK_SPACE/NewRepo.git"
5. In c:\MyBranch, push MyBranch repo to NewRepo/MyBranch with the command: "git push https://ACCOUNT_NAME@bitbucket.org/WORK_SPACE/NewRepo.git MyBranch:MyBranch"
This will create a new branch called MyBranch in the remote repo NewRepo and push the files, folders and history from c:\MyBranch to NewRepo/MyBranch
6. Merge NewRepo/MyBranch to master. Remove the branch NewRepo/MyBranch if necessary
git.exe merge --allow-unrelated-histories remotes/origin/branch4
git.exe push --progress "origin" master:master
7. Now NewRepo will contain all the files, folders and history of MyRepo/MyBranch
I'm having a similar issue.
I plan to use git filter-repo, but run into some issues, maybe we can solve them together.
Note that git filter-repo will rewrite history, so I will copy it to a new repo. Please read the documentation!
You can install git-filter-repo using python3 pip3:
pip3 install git-filter-repo
I only got it working under linux, where you might want to use sudo to get the correct install path.
then you need a fresh clone of your repository:
git clone --bare --mirror <path to your bitbucket repo>
bare will only checkout the .git folder, and mirror will include all references.
git filter-repo --path <path to remove> --invert-paths
Will remove the selected folder / files.
Create a new empty repo on bitbucket.
git remote add origin <path to new repo>
git push --mirror
After this it should be done, but bitbucket lists my repo size as a few kB and it fails to list branches.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My concern is not to corrupt the current repo as it contains few more active branches.
Let me try with a test repo first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.