0

My friend and I are working on a project, I pushed my changes to the master branch, she pushed hers to another branch.

How can I now merge my and her code in the master branch?

jthill
  • 55,082
  • 5
  • 77
  • 137
kaws
  • 29
  • 6
  • Possible duplicate of [How do you merge selective files with git-merge?](https://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge) – Marcello B. Jul 18 '17 at 00:04

2 Answers2

0

If you both are using bitbucket then ask her to create a pull request to master branch. You or she any repository admin or owner will get notification about the pull request which can be merged. If any conflicts are the among he branch changes and your master branch based files then she has to pull the master code and merge that to her branch. Then she has to push back. The raised pull request will be automatically updated with new changes so owner will be able to merge. That's all your master branch is up-to-date with your code + her code

Resolving same file changes

Lets say after cloning you have updated c.file file from [a, b, c] file list and pushed the changes to master.

She has changed a.file & c.file file without knowing that you have changed in master. She has pushed the code into different branch lets say bug-1

// in your case
git fetch --all
git checkout bug-1
git merge origin/master
// you will get conflict in c.file. You have to edit the file manually to keep both or some changes.
git stage .
git commit
git push origin bug-1
// now bug-1 branch is up-to-date with master. Raise or merge pull request from bug-1 to master
// all she has to do after merge is
git pull
Priya
  • 1,522
  • 1
  • 14
  • 31
  • Ex: say I have files like a, b and c. I made changes to c and push to master and she makes changes a and c and push to her Branch. How can we have the updated code? – kaws Jul 17 '17 at 23:54
  • I don't understand your answer. Can you explain me based on the example above? – kaws Jul 17 '17 at 23:55
  • Updated the answer. – Priya Jul 18 '17 at 00:05
0

In the repo where you did your work:

git pull origin herbranch
resolve any conflicts here
git push
jthill
  • 55,082
  • 5
  • 77
  • 137