-1

So my partner and I are complete Git beginners and are having a hard time just following the terminology let alone making any sense out of the docs and online guides.

Here's the situation:

We have a git repo with a bunch of files. We both started with the latest master copy. My partner then made a bunch of changes on a new branch, whereas I made all my changes on my master branch.

Right now we want to combine our changes. We both worked on separate files, so really we only need to 'pull' (not sure of the terminology) each other's single file that we worked on.

Any help would be greatly appreciated. Thanks!

Clarifier

As an example, let's say there are 5 files: A, B, C, D, and E

We both pulled all the files. Partner worked on A in a separate branch. I worked on B on my master branch. Now I want to give him my B changes and to get his A changes. Thanks again

Jona
  • 1,023
  • 2
  • 15
  • 39
  • 1
    have you tried git merge? Read this for reference https://git-scm.com/docs/git-merge – Nirupa May 16 '16 at 23:36
  • Take some time and do some tutorials. All the specific answers to specific questions in the world will not really help you. You need to just invest some time to learn properly yourself first. – Mort May 16 '16 at 23:39
  • @Mort generally, you're right. but sometimes you just need a good solid example to make things click. – Jona May 16 '16 at 23:41
  • Possible duplicate of [Best (and safest) way to merge a git branch into master](http://stackoverflow.com/questions/5601931/best-and-safest-way-to-merge-a-git-branch-into-master) – Whymarrh May 16 '16 at 23:41

1 Answers1

1

I think you just have to apply git merge.

Before that,

1) Commit and push all the changes of the branch to the remote. Lets say if your branch name is partner and assuming you are working on mac, these are the below terminal commands to commit your parner's stuff.

git commit -m "Changed something and added something"
git push origin partner

Remote is upto date with your partner branch changes.

2) On the master branch, apply a merge

git fetch origin 
git merge origin/partner

This means you are merging the partner remote branch to the local master branch.

3) Changes are merged into the local master branch. Now push all the changes to remote master (some times you need to do a commit if there any local changes)

git push origin master

Hope this helps you.

Cheers,
Sha

sha
  • 1,410
  • 2
  • 18
  • 37
  • cheers. Also look at `git status` command to check the local changes – sha May 16 '16 at 23:51
  • wait just tried this, and i got `merge: partner - not something we can merge` – Jona May 16 '16 at 23:52
  • whats the branch name you want to merge? – sha May 16 '16 at 23:53
  • `navbar` - i was just saying `partner` to conform with your example, but i did do `git merge navbar` – Jona May 16 '16 at 23:54
  • does it matter that i didn't do a pull/fetch/checkout? – Jona May 16 '16 at 23:54
  • 1
    Can you try `git branch -a` and tell me what you see? This is to see all the local and remote branches – sha May 16 '16 at 23:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/112094/discussion-between-jona-and-sha). – Jona May 16 '16 at 23:59
  • hmm.. I think your branch `navbar` is not in the remote. Have you pushed the branch `navbar` to remote? – sha May 17 '16 at 00:00