Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge branch without deleting it in git

Tags:

git

git-merge

Can I merge a branch without deleting it?

If I have branch "personal-work-in-progress", and a branch "feature/ABC-123" that is five commits ahead of it, is it possible to merge the five commits from feature/ABC-123 into personal-work-in-progress without deleting the feature/ABC-123 branch?

I know doing five git cherry-pick commands would do it, but that seems a bit tedious and error-prone.

like image 694
Andrew Grimm Avatar asked Nov 19 '15 00:11

Andrew Grimm


People also ask

Does merging a branch delete the branch?

The more the branches and master diverge away from each other the farther away their “common ancestor” commit becomes. When you're done with a branch and it has been merged into master, delete it. A new branch can be made off of the most recent commit on the master branch.

Can you merge branches in git?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.

How do I merge an already merged branch?

You can do it like this: git checkout missing-commits git checkout -b correct-merge git merge D # do it right, this time around!


1 Answers

Try this

git merge branch_name

https://www.atlassian.com/git/tutorials/using-branches/git-merge

like image 73
kdlcruz Avatar answered Oct 24 '22 16:10

kdlcruz