0

I have one Branch that I have a lot of changes and rebasing. Although, right now I wish to create a new branch with all my changes to this new Branch. For example, I have the Branch Developer with 10 Commits, now I wish to create the Developer v2 with all 10 commits in only one commit in this new branch, so I can take the Developer v2 and start to work on it and delete the Developer.

EDIT: My question is a little bit different, I don't want to transform all my commits in only one and commit in master for example. If I wish I can do it: git checkout master git pull git checkout <branch_name> git rebase -i master Git checkout master git merge <branch_name>

What I want is create a new branch from master called v2 and them apply all my changes of the branch developer on V2, so I can delete the Developer Branch and they don't have any relation.

  • 3
    Possible duplicate of [Squash my last X commits together using Git](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) – Quentin Mar 12 '18 at 09:54
  • It sounds like you're talking about *commit squashing*. – Oliver Charlesworth Mar 12 '18 at 09:54
  • Hmmm Quetin and Oliver, not like that. For squash in one commit I can do `git checkout master | git pull | git checkout | git rebase -i master | Git checkout master | git merge ` What I really wish to start a new branch with only one commit, but with all my old changes from my old branch. So I create a new branch from Master for example and apply all my changes of the old branch in this Branch – Guilherme Felipe Reis Mar 12 '18 at 10:04
  • 1
    Did you try first creating the new branch based on the Developer branch, then squashing the commits, which will only apply to the new branch? – ypnos Mar 12 '18 at 10:15
  • No, I didn't ypnos. I will try it – Guilherme Felipe Reis Mar 12 '18 at 10:26
  • 1
    That's still a squash-like operation, and in fact, you might want to use `git merge --squash` to achieve it (note that this kind of `git merge` does not make a merge!). – torek Mar 12 '18 at 17:02

1 Answers1

0

I think I found what I wish and it calls patch.

git diff master Branch1 > ../patchfile git checkout Branch2 git apply ../patchfile

Answered in here, so everything that I did on Branch1 can be applied to Branch2. It worked really good for me.