Although this is not a Julia question, but a git question, I think it is likely that someone has already done something similar, given how Julia packages are git repos.
Anyways, we have two versions of the package ClimateBase, one in JuliaClimate and one on my account:
- https://github.com/JuliaClimate/ClimateBase.jl
- https://github.com/Datseris/ClimateBase.jl
I initially started working on (2) as a draft, and I did not have the foresight that it would become a full rewrite of the existing ClimateBase.jl.
We now want to merge my version into the JuliaClimate version while keeping git history for both. The problem is, my version is not a fork… it is a brand new repo that doesn’t have any git connection with the original. I’ve tried some tutorials on google on how to do this, e.g. https://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/ but it didn’t work at all!
Is it possible? Anyone has any idea? I think what @SimonDanisch did for MakieLayout in this PR: https://github.com/JuliaPlots/AbstractPlotting.jl/pull/449 is pretty much what I want to achieve as well…
1 Like
Make one commit that deletes everything (see commit #1 here: https://github.com/JuliaSparse/Metis.jl/pull/29) then you rebase your commits on top of the (empty) branch.
Thanks a lot for the reply!
I’m trying to do as you instructed. I’ve created a new branch merge_datseris
from the old master, and deleted everything in it. And committed the deleted files. Then, I make another branch from_datseris
, that starts from the new master.
I am then doing
git checkout merge_datseris
git rebase from_datseris
the problem is, at every step I get messages like:
m300808@Lenovo024:/c/Users/m300808/.julia/dev/ClimateBase$ git rebase from_datseris
error: could not apply 3b503b7... new uuid + name
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 3b503b7... new uuid + name
CONFLICT (add/add): Merge conflict in src/ClimateBase.jl
Auto-merging src/ClimateBase.jl
CONFLICT (add/add): Merge conflict in Project.toml
Auto-merging Project.toml
m300808@Lenovo024:/c/Users/m300808/.julia/dev/ClimateBase$
so there are conflicts all the time. The conflicts persist throughout the commits: even if I fix these first conflicts and mark resolved, there will be another conflict on the next commit.
This worked for me without any conflicts:
# Clone the repo we want to keep
$ git clone https://github.com/JuliaClimate/ClimateBase.jl JuliaClimate-ClimateBase
# cd to it
$ cd JuliaClimate-ClimateBase/
# Checkout a new branch
$ git checkout -b delete-it-all
# Delete everything
$ git rm -r '*'
# Commit the deletion
$ git commit -m "Delete it all"
# Add the other repo as a remote
$ git remote add Datseris https://github.com/Datseris/ClimateBase.jl
# Fetch the repo
$ git fetch Datseris
# Checkout a branch from the other repos master
$ git checkout -b new-world Datseris/master
# Rebase on top of the empty branch
$ git rebase delete-it-all
4 Likes
Thanks a lot, this indeed worked for me as well. Perhaps I shouldn’t be using GitKraken that often! (I completely screwed up after though and pushed directly to master instead of doing a PR, but oh well, I learn every day)