Alex Rivera | Logout

Unable to understand Git branch, merge and rebase

Asked 2009-05-24T18:17:33.500
9

I know the thread which says that rebase is for small changes of teamMates, while merge for large changes.

I keep three Gits of three teammates in the following directory structure where we all have the same initial code:

project 
      | - I
      | - myTeamMate1
      | - myTeamMate2

The branches are not in the same Git. This means that I cannot use rebase and merge. I have used vimdiff to sync changes between teamMates. However, this is time-consuming.

I have unsuccessfully tried to make the following directory structure where all branches are under one Git:

project
      | - I - myTeamMate1 - myTeamMate2

However, I run clone command for me and for my teammate:

git clone <url>

and I get the error message after running the second clone for my teammate

fatal: destination path 'dotFiles' already exists and is not an empty directory.

Which directory structure should I use with a team of 3 people, such that I can use rebase and merge commands?

Edit
Report

1 Answer

4

Truth be told, I started to work on typing a nice, long, detailed response... but I this is already explained much better than I could at http://excess.org/article/2008/07/ogre-git-tutorial/. He covers the use of different branches, remotes, and merging. It's also done in screencast, so take an hour, grab some coffee, and enjoy the lecture.

Specific to your question: you shouldn't use a directory setup. Git doesn't handle branching with directories in the same way that SVN does with branch folders. Branches in git are an entirely different thing. While you may not setup a central repository (I recommend it), you should setup a single master branch that everybody commits their final, clean work to.

One example repository of mine has a screenshot at Wikimedia Commons. In my example, "bartender" submits his code only in tar chunks, so I have to import it myself to manage it. "master" (shown here only as remotes/elf/master) is a public svn repository that I import and base changes off of. "autocracy" is my own baseline for the code, and "private" is where I keep a config file with passwords that I want to manage but never publish. Check the timestamps on private, and you'll notice they don't line up with the branches below. This is because I rebase that branch onto "autocracy" instead of merging.

You'll notice two remote references: elf and bard. These are two remote machines of mine that host the software. I can push and pull my branches to there as I wish. In your case, you'd have remote repositories of your other developers, and they'd modify their own branches. Watching the tutorial will give you a better idea of how it works. Good luck :)

answered 2009-05-25T14:36:05.630

Your Answer