How to merge single files with git?

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


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

链接地址: http://www.djcxy.com/p/49314.html

上一篇: 使用git作为研发工具

下一篇: 如何合并单个文件与Git?