-1

I have a branch X, from that one I made branch Y, and from that one I made branch Z.

I made changes in Z but not in Y. I want to bring all the changes from Z into Y and delete Z. I know it's a simple merge but I don't want to mess it up!

j08691
  • 197,815
  • 30
  • 248
  • 265
nick
  • 2,397
  • 4
  • 26
  • 46
  • Does this answer your question? [Git merge branch into master](https://stackoverflow.com/questions/14605231/git-merge-branch-into-master) – Amit Gandole Nov 30 '20 at 17:50

3 Answers3

1

assuming you are on branch Z

git checkout Y
git merge Z
git branch -d Z # this will delete branch Z only if there are no new changes on Z, it is a sage delete so to say, force delete is -D (uppercase)

if branch Z has also been pushed to remote and you also want to delete it there you need to

git push origin --delete Z
caramba
  • 21,282
  • 18
  • 84
  • 125
1

Or you could put Y where Z is and drop Z

git branch -f Y Z
git checkout Y
git branch -d Z
eftshift0
  • 20,217
  • 3
  • 33
  • 45
0

You need to use git merge command.

Go to branch Y : git checkout Y

Merge branch Z into Y : git merge Z

Delete branch Z : git branch -d Z

Read this for more reference : https://git-scm.com/docs/git-merge

Amit Gandole
  • 535
  • 6
  • 17