Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My group partner and I are creating a MySQL database application with a GTK# frontend. Our application consists of a main window with information displayed in multiple tabs. My partner started most of the implementation, then he gave me a copy of the project folder so I could implement half of the tabs and he could do the other half.

Now we want to merge our work back together, but we weren't using source control (yeah, yeah, I know...) and we aren't sure how to easily smush them back together by hand. His portion of the code is now hosted on GitHub, and we're wondering how we might use git to merge my unversioned code in with his. Any suggestions?

share|improve this question
1  
Have you considered using source control such as Bazaar ;)? You can still use source control even after developing the project. You would just need to make sure to upload your changes (and pull them in) after he creates the base repository. –  RolandiXor Mar 19 '13 at 23:24
    
Okay, we're using GitHub now to host our project, but we're still unsure how to merge my code in with his after I pull his with git clone. My code is in another folder on my computer at the moment. –  WarriorIng64 Mar 20 '13 at 0:06
    
I'm suspecting part of the solution might involve the use of diff to generate patches, but I don't think I know enough to make a full solution off of that. –  WarriorIng64 Mar 21 '13 at 20:29
add comment

1 Answer

His code, and your code, should share a common origin.

What you need is a git repository with this common origin as a revision.

His code state should use this common origin as a parent, so should yours.

That copy he gave you should do - if you still have an archive of it.

  1. Create a new git repo
  2. Copy the origin code into it
  3. Add and commit
  4. Now create and check out a new branch for his code (git checkout -b his-code)
  5. Delete all the origin code, put his new code in
  6. Add and commit
  7. Check out the origin code again (git checkout master)
  8. Make a new branch for YOUR code (git checkout -b my-code)
  9. Delete the origin code, put in your code
  10. Add and commit

Now you have a repository with the history of both your changes from a common origin. Merging these two branches should produce the desired result.

git checkout master
git merge his-code
git merge my-code
share|improve this answer
    
By "origin code", you mean the initial code he wrote that I'm trying to merge my unversioned stuff back into? –  WarriorIng64 Mar 21 '13 at 20:40
    
Yup, the initial archive of code that he sent you. This is the last known common revision that you both had at one point. I don't mean the Git convention of calling the branch you cloned "origin" (sorry for confusion), –  Adrian Mar 21 '13 at 20:46
    
At Step 6, I run into a problem with git where git add . runs without output, but subsequently running git commit just tells me there are no changes to commit. Is there a way to force a commit without changes? Because the code from Step 5 is the same code as from Step 2. –  WarriorIng64 Mar 21 '13 at 21:02
    
Okay, I got past that by just doing a touch junk.txt so that there would be a negligible difference and allow me to do the commit. However, when I open the project up in MonoDevelop, my stuff's there but not his. –  WarriorIng64 Mar 21 '13 at 21:14
    
If his new code in step 5 is the same as the original code in step 2, then he has made no changes since he gave you the code. Therefore your code should already represent the complete merged code. As long as it's true that he hasn't changed anything. –  Adrian Mar 21 '13 at 21:23
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.