简体   繁体   中英

git orphan branches with same commits

I want to create an orphan branch that copies all the commits across.

Basically I need to end up with master and dev, both orphans but both identical (until I make further commits).

I have created the orphan master (empty) and have the dev with all my commits. How do I copy all these commits to master?

(Not judgin if orphan branch is the right solution here, just trying to answer the initial question which was about duplicating history.
As nneonneo comments regular branches are probably fine )

The problem is that if the SHA1 are the same between the two branches, the second branch will always be a simple pointer to a commit of the first branch.

What could work is:

That would looks like:

cd /original/repo
git fetch /path/to/clone master:dev

And that would create an orphan branch dev , with all the (same) commits than master (on top of an empty one)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM