1

I've seen this answer, but I'm unsure of what the answerer meant by using git branch -f .. in order to complete the task.

I have three branches, my master branch has a bunch of files that I don't want sticking around, which I know they will if I use merge. I somewhat understand deleting a branch, but can I really do that to the master branch?

I know there is a probably simple solution to the problem, but could someone explain what each git command is doing? It would help a fair bit.

Question: How can I merge my sub-branch into the master while only keeping the files from the sub-branch and none from the master whilst keeping my sub-branch?

aynber
  • 22,380
  • 8
  • 50
  • 63
RileyE
  • 10,874
  • 13
  • 63
  • 106
  • @AlessandroVendruscolo Oops. I guess I forgot to reiterate properly. I think that will help a bit. I'm trying to figure out the best way to get my sub-branch to become my new master branch without losing my sub-branch. – RileyE Nov 28 '12 at 16:03

1 Answers1

1

You can checkout the sub-branch, delete master branch, checkout a copy of your sub-branch and name it master.

git checkout sub-branch
git branch -D master
git checkout -b master
OneOfOne
  • 95,033
  • 20
  • 184
  • 185
  • So deleting master doesn't have any implications? And this is the best way to do it? – RileyE Nov 28 '12 at 16:07
  • This depends on wither your repo is pushed online or not, if it is it might cause problems for other users, if it's just a local repo, it has 0 implications, you don't even have to work on master branch at all, it's just a name. – OneOfOne Nov 28 '12 at 16:08
  • Oh. I guess when so many people always referred to master versus branches, I always thought of it as some superior being or whatnot. Could you also explain what git branch -f is doing? I'm looking at the docs, but I don't quite get it. – RileyE Nov 28 '12 at 16:17
  • I have never used it, doesn't make much sense to me either. – OneOfOne Nov 28 '12 at 16:18
  • 1
    @OneOnOne Okay. Well, thank you for easing my mind about deleting the master. – RileyE Nov 28 '12 at 16:19