-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
  • 204,283
  • 31
  • 260
  • 272
nick
  • 2,819
  • 5
  • 33
  • 69
  • 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,963
  • 19
  • 86
  • 127
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
  • 26,375
  • 3
  • 36
  • 60
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
  • 558
  • 8
  • 20