1

I have a master with files A, B, C I have a branch called 'feature' with files: D,E,F.

Yes my branch was NOT cut off of my master, so the files are nothing alike between branch and master.

Now I want to essentially replace the content of my master with what's in branch.

What can I do?

phd
  • 82,685
  • 13
  • 120
  • 165
user1008636
  • 2,989
  • 11
  • 31
  • 45

3 Answers3

1

You can try the following:

git checkout feature git merge -s ours master git checkout master git merge feature

Reference: https://git-scm.com/docs/git-merge

0

I want to...replace the content of my master with what's in [feature]

Sounds like you don't want to merge at all. I would do this:

git checkout master
git tag old-master
git reset --hard feature

A branch in git is not a container for files: It's nothing but a name for a particular commit.

The git checkout master command does two things;

  1. It makes the workspace look like whatever the master commit says it's supposed to look like, but we don't care about that, and
  2. It makes master be the "current" branch.

The git tag old-master command is optional: It makes a new name (old-master) for the commit that's about to not be master anymore, just in case you might ever want to find it again.

git reset --hard feature is the money command: It does two things;

  1. It changes the current branch (master) to refer to the same commit that feature refers to, and
  2. It re-checks it out, making the workspace look like what the master/feature commit says it should look like.
Solomon Slow
  • 25,130
  • 5
  • 37
  • 57
0

if you replacing the full contents of master with feature than you need to remove everything from the master then, right? than this should do:

git checkout master
git rm -rf *
git merge feature
Serge
  • 11,616
  • 3
  • 18
  • 28