The upstream repository was on github, say "droid". I forked it and add some commits in my fork. But upstream repo "droid" was moved to subfolder to another existing repo, say "allRepo", and now it is in "allRepo/droid". I forked it too. Can I move my commits from my_fork_1 to my_fork_2 (or locally), and continue work with my_fork_2, which is fork of "allRepo"?
Making some formerly separate project (with it's own separate repository and separate history) a part of some larger project at some subdirectory (subtree) is a subtree merge , and is described eg in " How to use the subtree merge strategy " HOWTO in git documentation, " Git Tools - Subtree Merging " chapter in "Pro Git" book (CC-NC-SA 3.0 license), and " Working with subtree merge " GitHub Help page (in Advanced Git section).
Note that you need to set up subtree merge only once; all future merging from subproject repo to whole project repo would get applied automatically. Or you can switch to using whole project repo after merging your commits into it.
There is also git subtree
command, available in contrib
area since git 1.7.11
One solution, is not apply the diff from the first git to the second one
In the first repo:
git diff <hash> <hash>~1 > patch
In the second:
git apply /some/path/to/the/patch
git commit
And get the message of the first repo with the following command:
git log <hash> -n 1 | tail -n+5 | sed -e "s/^ *//"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.