I have a branch of code I have been developing locally. I included some information in a file that I do not want to make public. I have removed the info but it would still be discoverable in previous commits. Is there a way to merge just the current commit of a branch into another branch in a way that doesn't preserve the history.
Asked
Active
Viewed 42 times
1
-
Try cherry-picking the commit you want. – Lasse V. Karlsen Mar 24 '17 at 13:42
-
1What a shock: marked as duplicate, but the answers to the "original" question don't address the OP's actual need. – Mark Adelsberger Mar 24 '17 at 13:52
-
2@LasseV.Karlsen - You (and apparently meagar) are getting thrown off by OP's poor choice of words. He wants the commit to produce the final tree, which means including changes form previous commits (except for those he reverted in later commits to conceal sensitive information) which would be excluded by cherry-picking. – Mark Adelsberger Mar 24 '17 at 13:53
-
1That is correct @MarkAdelsberger thank you for clarifying my language. – Robert Corey Mar 24 '17 at 14:02
-
I've tried to address the subject line wording. – torek Mar 24 '17 at 14:19
1 Answers
2
you can use
git merge --squash
This will squash all the commits from your development branch into one single commit. See this answer

Community
- 1
- 1

Chris Maes
- 35,025
- 12
- 111
- 136
-
@meagar. If this is a duplicate; I think it would be more duplicate for a question containing `git merge --squash`. I think the OP has more than one commit containing his developments and he clearly wants to squash thos together. – Chris Maes Mar 24 '17 at 13:48
-
This is almost certainly the simplest answer, if OP is truly happy without any of the intermediate history (which it seems from the question would be fine). If intermediate history is needed, then cleaning up the local branch with `filter-branch` or with the BFG repo cleaner before pushing would be the solution. – Mark Adelsberger Mar 24 '17 at 13:54
-
Not clean enough history for filter-branch, above solution is fine, thanks everyone. – Robert Corey Mar 24 '17 at 14:03