Sunil Kumar
Sunil Kumar

Reputation: 27

I want to merge master and a branch containing completely different data

I was working on project which had two sub directory. I by mistake completed my work of first directory in branch named additional and after that when I was completing work of second directory I uploaded all the files to master and commited my all work in master now my branch additional contains both directories but only commits on my first work and second work is untouched(same as the codes at start). And my master contains all the files of my second work but no trace of first work and all commits are regarding this second work.So how can I merge these two into a single master containing my all the work and all the commits.

Upvotes: 1

Views: 241

Answers (1)

DilumN
DilumN

Reputation: 2897

I think the better way is to use git rebase

First of all take the latest master to your local repo

git pull --rebase

Then checkout to feature-A branch

git checkout feature-A

Then rebase feature-A branch

git rebase master

If you get any conflicts, fix them &,

git add .
git rebase --continue

untill you finishes your rebase.

Then force push your feature-A branch

git push origin feature-A --force

Now you are good to go with the merging, because you have all your master branch changes also in feature-A branch

You can create a pull request & merge, or else checkout to master & git merge feature-A

Upvotes: 1

Related Questions