A university colleague of mine thought it was a good idea to fork a repository by cloning it and copy its contents into a new, freshly initialized repository but without the
A <- B <- C <- D <- E (original repository)
\ clone / |_____|
\ / |
\ / Ofc. work on the original repository was continued after cloning...
M <- N <- O <-P (our "fork", commits from my team)
A <- B <- C <- N <- O <- P
git diff > /path/to/patch
git reset --hard COMMIT_HASH_A
N <- O <- P
git format-patch COMMIT_HASH_M --stdout > /path/to/patch
git am -3 /path/to/patch
fatal: sha1 information is lacking or useless (some_file_name).
Repository lacks necessary blobs to fall back on 3-way merge.
If you don't insist on linear history, you can merge your fork into original repository.
In the original repo drirectory:
git remote add fork /path/to/fork git fetch fork git merge fork/master
This will preserve commits and may result in liner history (no merge commit) if the merge can be fast-forwarded.