views:

106

answers:

2

we are using git on a lan of computers and we have a central repository on one machine, every developer has to clone the repository and work on his one machine. but how to merge all this repositories together in the central repository ?

+2  A: 

Simply have each developer push to the main repository. Git is smart enough to merge them, most of the time.

$ git add .
$ git commit -m 'committing my changes'
$ git push origin master


Since git push does not merge, you could have each developer push to a branch on the central repository, and then when you're ready, log on to the machine that hosts the central repo, and merge them with git pull . <branch-name>. Just make sure git branch displays an asterisk next to the master branch before merging.

Blaine LaFreniere
push does not merge.
Alex Brasetvik
As noted by Alex, Git won't merge on a push. However, you can still have each dev just push into the main repo; if, say, Dev 1 pushed after Dev 2 did his last update, Dev 2 would get an error when pushing into the repo, in which case he could just do a `git pull`, merge Dev 1's changes into his repo, and then push the new (merged) changes into the central repo.
mipadi
Thanks for the clarification.
Blaine LaFreniere
I got such a problem but after each merging I just do git reset --hard if I want it to appear in the main repo
sultan
+2  A: 

Short version: git pull is the equivalent of fetch + merge. You can --- by default --- only push "fast forward" changes, which means you've either merged or rebased your uncommitted changes. Contrary to what Blaine suggests, push has nothing to do with merging.

Longer version: You seem to not understand quite how Git works. As source control is an integral part of software development and you're using it, I suggest you read up on how Git's data model works --- and how to implement various workflows with it. Excellent source: http://git-scm.com/documentation

Alex Brasetvik