Squash git captures what is the ancestor of several branches

I cloned an existing project repository through github, which copied all the stories and commit branches. I would like to delete the entire commit history from the branch of the cloned project wizard and save the commit history from the branches I worked with (see. Diagram). The project is as follows:

A [master]
\
  B [branchDevelop] ________
   \                        \
     C [branchFeature1]      D [branchFeature2]

I tried reloading and crushing commits in the main thing, but I continue to encounter merge conflicts. Also, if I remove .git and reinitialize the project, I will lose my branches. How to delete the wizard commit history and save the development branches and commit that I'm working on?

+4
source share
2 answers

, master, master history:

git checkout --orphan new_master master
git commit -m'squashed'

: !

  • .
  • , !

branchDevelop, git filter-branch:

git filter-branch \
    --parent-filter \
        "test \$GIT_COMMIT = $(git show -s master --format=%H) \
            && echo '-p $(git show -s new_master --format=%H)' \
            || cat" \
    --tag-name-filter "cat" \
    -- \
    branchDevelop branchFeature1 branchFeature2

, master master:

git branch -M new_master master
0

?

git branch -M branchDevelop master

, , . :

git push -f origin master
-1

Source: https://habr.com/ru/post/1606305/


All Articles