Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to use git in a mutli-user environment,


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 TheCreeperLawyer   Members   -  Reputation: 117

Like
0Likes
Like

Posted 25 December 2012 - 11:14 PM

Hello everyone and Merry Christmas,

 

Me and a friend have started working on some stuff together and we've decided to use git as our version control system. We keep running into issues with fast-forward errors. We're both working in one branch (master) and we often commit and push at the same time.

 

I'm wondering how we should best make use of egit on eclipse to try and avoid these issues. We're hosting on bitbucket if that helps. Should we both work in local branches then merge them before pushing or something like that?

 

There is very little information from what I can see on this (maybe I'm just wording it wrong in Google  and I would really appreciate some really in depth articles that describe it well, plus if they have a focus on egit as well that would be awesome, but it's by no means necessary.

 

Any help would be greatly appreciated. Thanks!



Sponsor:

#2 TheCreeperLawyer   Members   -  Reputation: 117

Like
0Likes
Like

Posted 25 December 2012 - 11:49 PM

Doing some more searching  I found this. Looks interesting and sort of describes what I'm looking at. I would still really love some good articles so if anyone has anything It would be really great.

 

Thanks.



#3 Bacterius   Crossbones+   -  Reputation: 8468

Like
0Likes
Like

Posted 26 December 2012 - 02:02 AM

Well, yes, git is not google docs. What's happening is that initially, your two local repositories (the one on your computer and on your friend's) are synchronized, but when your friend pushes his modifications to the main repository, that repository is now out of date with yours, and when you try to push your own modifications, the push will probably fail since your repository is out of date. In this case you need to update your repository (git pull) and hope that doesn't trash your work in case your friend was working with the same files you were. Then you should be able to push (unless your friend pushed again since then, as you can see this can be frustrating).

 

A good idea is to not push as often - prefer to just commit, which only makes changes to your local repository, and only push once you've accomplished enough work and your friend can update his repository (hopefully you didn't write over what he is currently working on - good project management will prevent that). In fact, ideally since you are working on unrelated features of a modular system, people don't need to pull your modifications to keep working, unless it's a major bug that affects the entire codebase. They'll just do their own stuff, push to their respective files and the end user can then grab the most up to date repository, regardless of who's done or not. This doesn't directly apply to you, obviously, since on a two-man team the code you're working on will likely be very related, but the idea still stands - don't push unless your friend needs your code to keep working (or you are finished for the day).

 

Another approach is to push to an integration manager (as you saw on those links above) which'll optionally decide what to pull into the repository (for non-trusted collaborators) and merge everything together correctly, in case you were working on the same things. This is important in big projects with lots of random collaborators, since people don't communicate as much between one another and you can't just trust people to behave properly and not break each other's code, so you have a "gatekeeper" which prevents that.

 

The bottom line being that there is no good way to work together on the same piece of code, really. The whole point of collaboration is to get work done faster, and you can't achieve that by having people fight over the same lines of code. It's like asking nine woman to have a baby in a month, it doesn't work that way. So perhaps for a two-man team you could try to divide your work by having your game logic (is it a game you're making?) flexible, accepting well-defined interfaces to whatever modules you are going to use, and then have him work on the character system while you get the graphics up and running, etc.. does that make sense?


Edited by Bacterius, 26 December 2012 - 03:22 AM.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#4 ifthen   Members   -  Reputation: 820

Like
0Likes
Like

Posted 26 December 2012 - 03:02 AM

Why not use three branches (master, one for you and one for your friend)? That way, you can both push the code. When made sure that your code in your branch does work, you can merge your branch to master. After that, your friend can merge master to his branch and continue working happily.



#5 TheCreeperLawyer   Members   -  Reputation: 117

Like
0Likes
Like

Posted 26 December 2012 - 03:50 AM

I've thought of branching, but I wondered if it was the appropriate thing to have a branch per developer. I saw in the link I found that in git, you can fetch then merge, then push which means you won't get a non-fast-forward error.



#6 SimonForsman   Crossbones+   -  Reputation: 6032

Like
1Likes
Like

Posted 26 December 2012 - 06:07 AM

<blockquote class="ipsBlockquote" data-author="TheCreeperLawyer" data-cid="5014370"><p>I've thought of branching, but I wondered if it was the appropriate thing to have a branch per developer. I saw in the link I found that in git, you can fetch then merge, then push which means you won't get a non-fast-forward error.</p></blockquote><br />Thats pretty much what we do, commit -&gt; pull -&gt; push , git merges changes automatically even if they are made to the same file. Branches are only made to separate development of new features from maintaining the stable release.
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#7 Bregma   Crossbones+   -  Reputation: 4964

Like
0Likes
Like

Posted 26 December 2012 - 09:38 AM

You should probably understand there is no such concept of a "master" branch in git.  You might have a local repo with one or more branches, your friend might have a local repo with one or more brances, there might be a repo at bitbucket with one or more branches.  You'll probably designate one of the branches at bitbucket as the one from which releases are made.  You probably work with one of your local branches.  there is nothing special about any of those branches except how you have decided to use them.

 

In my experience, the best practice with git is to have a local copy of the designated release branch locally, and have that one labeled 'master' (which is the default label for a newly created branch in a repo and easily created from the remote release branch using 'git clone').  Do your work on a separate local branch called 'develop', and even use feature branches from that branch for individual features.  Branching is very very cheap in git, more branches are better. Before pushing your work up to the release branch, synchronize your local copy ('master') with the remote, then merge your work on to it (fixing any conflicts if necessary).  The, push that to the remote release branch.

 

I've found this to be a nice workflow for any DVCS.


Stephen M. Webb
Professional Free Software Developer




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS