views:

138

answers:

5

I have a source directory that includes a mix of different languages and files. Probably 100+ total files. I want to 'fork' that code and create a completely different version of the source. At this point, I will have version-1 of the code and version-2 of the code. I will not make that much development on version-1. I want to change the documentation headers and some other small changes. I will do a lot of development on version-2 and then come back a month or two later and merge version-2 with version-1 (set the latest version-2 to version-1).

But, I don't want to lose any changes that I made to version-1 (say after months of small fixes).


Here are some other conditions that I would like to have.

  1. I don't want to centralized version control like subversion (This source isn't under subversion anyway).

  2. I was thinking I could use 'git' and then perform git on version-1 and version-2 as of right now. Do development on version-1 and then do two months of development on version-2 and then do a merge with git.

My only concern with git. A. Ideally, I wish I could create the git repositories 'after' I have done ALL of my development on both version-1 and version-2 at one moment in time, say after two months of development on both repos. I would rather do this one time git create repository so that I could avoid doing a bunch of incremental commits?

B. I assume I might need some git GUI tools once I need to merge? Does git have any tools.

C. I hate the .git repository files, I would have to remove all of that after all my development on both repos. It might be hard to clear those.

...back to my numbered options.

  1. Use the diff and patch command. I really hate to do this because duff/patch seems to basic.

  2. Some other merge tool?

+3  A: 

Whilst I don't agree with your stance on not creating repositories until after 2 months of development, a tool you might find useful for merging entire directories is Beyond Compare. Beyond Compare let's you do folder comparisons.

Here's a screenshot of Beyond Compare comparing folders.

RichardOD
+1 for beyond compare, i use this tool with success as well.
Jon Erickson
@Jon, yes it is a very nice tool. I've also used KDiff3 which I also thought was good.
RichardOD
Will it allow you to do a merge?
Berlin Brown
@Berlin- yes it will allow you to do a merge.
RichardOD
+1  A: 

Regarding not using subversion or similar version control tool, you say you don't want to use one? Why? It would be the ideal solution to your problem.

Second of all you say you don't want use diff and patch, you do understand that many version control systems use the very same diff and patch tools you are saying are too basic ;)

Thirdly, if you found a better "diff and patch tool" you will have to do the following

diff V1_start V1_end > patch_file; patch V2_end patch_file.

Therfore you still must keep older version of your V1 software (otherwise you can never do a diff!). Instead of doing that manually, why not use a version control system to keep track of the versions for you?

hhafez
I said subversion or CVS. Centralized source control. I could go for something more distributed like git or mercury.
Berlin Brown
if centralised vs distributed is a big deal for you then use git :)
hhafez
+3  A: 

Your situation is called a "branch", one of the foundational concepts of source control systems.

Use SVN(or Git, or Hg, or CVS, or....) and get the job done, and done right.

Paul Nathan
That is great, but would be easiest to do locally as well as cleanup afterwards.
Berlin Brown
So you use Hg or Git, and branch locally....
Paul Nathan
+3  A: 

git only creates A SINGLE .git directory. svn is the one that scatters .svn directories in EVERY directory.

Your time would be far better spent learning useful git commands (such as git merge --squash). Use git, it will do exactly what you want with no trouble.


Edit:

With git, you can keep it all in one place, switch back and forth at a whim, and make as many commits as you want.

In order to reduce conflicts, you may want to keep Phase1 merged into Phase2 (as you make infrequent changes in Phase1). But that is totally up to you.

Here is how I would do it with git:

cd /path/to/project
git init
git add .
git commit -m "Initial Commit"

At this point, you are on the master branch with a single commit called "Initial Commit". Now, let's create branches.

git branch Phase1
git branch Phase2

Now, to work on Phase2:

git checkout Phase2
... work ...
git add ...
git commit

Switch to Phase 1 and do some work.

git checkout Phase1
... work ...
git add ...
git commit

Switch to Phase 2 and do some more work.

git checkout Phase2
... work ...
git add ...
git commit

At the appropriate time, pull changes from Phase1 into Phase2 (or the other way around):

git checkout Phase2
git merge Phase1
... resolve any conflicts and commit if needed ...

Repeat... You'll be able to make as many commits, merges, and branches as you need to stay on top of the project.

Also, use git tag ... to create tags that point to a given commit. That way you can always go back without having to sort through the history.


Edit:

We run git from the command line, so I am not very familiar with what GUI tools exist. It should not be hard to find.

When you run into a conflict, git marks the files as conflicted (git status) and also merges them as best possible. Where the merge cannot complete, it leaves very clear markers in the files:

<<<<<<< yours:sample.txt
Conflict resolution is hard;
We went shopping yesterday.
=======
We go shopping today.
>>>>>>> theirs:sample.txt

So you simply delete one of the two, and edit the remainder to suit.

It rarely happens and is very easy to clean up.

gahooa
That is exactly what I was looking for.1. Do you think I need to see what happens during the merge. E.g. will git ignore conflicts or do I need a GUI tool to see the conflicts.2. Could I do it with one shot. Lets say I fork version-1 (copy the folder somewhere, make small changes), do 2 months of development in version-2 and then run all the git commands in one shot? Or is it better to do more incremental commits?
Berlin Brown
Hi Berlin: It really does not matter. I'll edit the post with more info.
gahooa
Perfect, thanks.
Berlin Brown
Another question, "... resolve any conflicts and commit if needed .."On this part, how does git resolve conflicts. I want to use a GUI tool and have it prompt me? Is that how git does it.
Berlin Brown
A: 

It is not entirely clear for me if it is what you wanted, but Git can merge independent projects / independent branches, which do not have common ancestor. For example git itself is merge of git code and mail tools for git (in very early history of git).

Jakub Narębski