Take the 2-minute tour ×

I am new to Git. I have a public repo on GitHub and me & my friend need to work on the project simultaneously. We are using Netbeans 7.1 which has built in Git features. I can clone from and submit to GitHub but for example consider we have the following structure:

  • A.java
  • B.java
  • C.java

    1. If User #1 changes A.java and User #2 changes B.java, how do we merge them?
    2. If User #1 and User #2 both changes C.java, what happens?

There is remote/Fetch & Remote/Pull and I cannot understand the difference. We will work on the school project as 4 people and we want to also learn version controlling.

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

git fetch fetches changes from the remote git repo but doesn't change you're local branches tracking the remote changes. Git pull is a git fetch followed by a git merge on your local copy.

Generally I do

git fetch
git status 
git merge

Merges will be done just like any other SCM. If conflicts arise you'll be given a chance to edit/fix them and then you'd have to push the changes to the remote repo for others to see. Users could also edit the same file and the changes won't result in a conflict and will just merge.

share|improve this answer
add comment

A pull in git equates to doing a fetch and then a merge.

When you do a fetch, it just retrieves the updated repository data, but doesn't merge the changes into your local working copy.

In the case of your examples:

  1. Git will auto merge the changes into your local working copy. Since the changes were in separate files (A.java & B.java) there won't be a conflict so git will just update the other file seamlessly.
  2. In this case it depends on where your changes are in the file C.java versus where their changes are.
    • If they are in difference places, git will just merge the changes together without an issue.
    • If the changes are in the same location in the file, git will mark the file as conflicted and ask you to manually resolve the differences.
share|improve this answer
add comment

What you need is a basic tutorial about git. I like this one: git Magic

The short answer is, git is built for EXACTLY this need. You just have to understand how it merges and combines changes from multiple users. But it works brilliantly once you understand it.

share|improve this answer
Nice tutorial btw thanks! –  Mustafa Dec 16 '11 at 21:45
add comment

Your Answer


