git-branch-sculpting

How to remove all commits of a topic Git branch?

我的未来我决定 提交于 2020-01-02 10:16:44
问题 Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their commits as following A-B-C-D-E master 回答1: You have a few options for doing this. Solution 1: Squash Merges One solution is to simply use a hard reset with a few squash merges: git checkout master git reset --hard C git merge --squash topic1 git commit -m "Rewrite D" git merge --squash topic2 git commit -m "Rewrite E" #

How can I combine Git repositories into a linear history?

£可爱£侵袭症+ 提交于 2019-12-17 23:34:21
问题 I have two git repositories R1 and R2 , which contain commits from two periods of a product's development: 1995-1997 and 1999-2013. (I created them by converting existing RCS and CVS repositories into Git.) R1: A---B---C---D R2: K---L---M---N How can I combine the two repositories into a single one that contains an accurate view of the project's linear history? A---B---C---D---K---L---M---N Note that between R1 and R2 files have been added, deleted, and renamed. I tried creating an empty

How to remove all commits of a topic Git branch?

拜拜、爱过 提交于 2019-12-06 04:18:31
Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their commits as following A-B-C-D-E master You have a few options for doing this. Solution 1: Squash Merges One solution is to simply use a hard reset with a few squash merges: git checkout master git reset --hard C git merge --squash topic1 git commit -m "Rewrite D" git merge --squash topic2 git commit -m "Rewrite E" # Verify that the new branch is no different from the old one git diff sha_of_old_E The idea here is that a

How can I combine Git repositories into a linear history?

老子叫甜甜 提交于 2019-11-28 21:27:19
I have two git repositories R1 and R2 , which contain commits from two periods of a product's development: 1995-1997 and 1999-2013. (I created them by converting existing RCS and CVS repositories into Git.) R1: A---B---C---D R2: K---L---M---N How can I combine the two repositories into a single one that contains an accurate view of the project's linear history? A---B---C---D---K---L---M---N Note that between R1 and R2 files have been added, deleted, and renamed. I tried creating an empty repository and then merging their contents onto it. git remote add R1 /vol/R1.git git fetch R1 git remote

Remove/hide git branches without deleting commit histories

不羁岁月 提交于 2019-11-27 13:04:49
问题 Situation: I have a main repo with a main dev branch and lots of "experiment" branches sprouting off from it (e.g., exp1 and exp2 ). The purpose of these experiment branches is to serve as placeholders for experiments that generate numerical results. I record the branch name (and commit ID) of the experiment branches so I can return to the commits to see precisely the code and history behind the results. But, now, there are so many experiment branches that it's getting hard to see the main