Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)

I have two branches, email and staging. staging is the latest one and I no longer need the old changes in email branch, yet I don't want to delete them.

So I just want to dump all the contents of staging into email so that they both point to the same commit.

 Is this possible?

1 Answer

0 votes
by (50.2k points)

For this, you can use the ‘ours’ merge strategy

Just go through the following commands that will help you to make current git branch to another branch

git checkout better_branch        # checkout to the branch

git merge --strategy=ours --no-commit master    #keep the content of this branch, record a merge 

But in this case you could do:

git checkout staging

git merge -s ours email # Merge branches, but use our branch head

This will help you to dump all the contents of staging into email.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...