Git: Copy source code to new branch without history

I have 2 branches in the git repository: commonand myown.

I want to copy the source from one branch to another branch, but I want the history of the branch to commonhave only a connection related to the migration of objects (from myownto common).

Is it possible to copy a source without a history or is a new repository required?

In addition, you may need to merge from commonbefore myownand after some changes to copy the source code as a new commit (and only like this commit - without the history of all other commits, as I said earlier).

+4
source share
2 answers

, , . , myown. ( ):

git checkout -orphan common

:

git .

:

git commit -m ""

( ). :

git checkout myown

( ):

...

git commit -m "feature1"

...

git commit -m "feature2"

, . common "release1"

git

git merge --squash myown

git commit -m "release1"

. common ( /, , 1). , myown.

+4

, :

git checkout <branch> -- .

<branch>.

<branch>.

, . <branch>.

EDIT: , , <branch>.

rm -rf .

+3

All Articles