N
N
Nazariy Lugovoy2018-11-09 00:19:45
git
Nazariy Lugovoy, 2018-11-09 00:19:45

How to merge a slave branch into master and replace all content?

Good time to all participants!
Tell the newbie how to merge a secondary (let’s say slave) branch into master so that it replaces all the contents of master with its own, and the data from master is deleted.
For example:
master>
index.php
a.php
b.php
d.php
slave>
index.php (modified)
b.php (modified)
c.php
d.php
output should be:
master>
index.php (modified)
b.php (modified)
c.php
d.php
as if the master branch should be deleted, and then the slave branch is renamed to master and then it becomes the main branch.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2018-11-09
@Nazariy

Tell the newbie how to merge a secondary (let’s say slave) branch into master so that it replaces all the contents of master with its own, and the data from master is deleted.

To have an honest merge and a continuous history:
git checkout slave
git merge -s ours master # смёржить master в slave, оставив только содержимое slave
git checkout master
git merge slave

S
Softer, 2018-11-09
@Softer

git branch -d master
git branch -m slave master

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question