[git-users] Re: How to merge two independent projects one commit by one commit?

2011-10-18 Thread www
Thank you. I have accomplished my goal successfully. Following is what
I did:

Again, I have all my work I did. It is located in the directory
mine/ and I use git to version control all my work. I received the
work files from my partner. He does not use any version control. He
sent me his tar files. Both he amd me are working on the same files. I
un-tar my partner's tar files into the directory partner/, which is
parralel with mine/.

cd partner
git init //create an empty git version control repository
git add xxx //adding the files into repository
git commit -a -m received files from my partner. He has finished his
part

//Now, I want to merge my work(my commits inside mine/, one by one) to
my partner's work
//still at the same location as above
git remote add my_work ../mine
git fetch my_work  //fetch all my commits into the remote branch
my_work
git branch -a //-a shows all branches
//shows the following:
* master
  remotes/my_work/master
git branch -r //-r shows remote branche
//shows the following:
  my_work/master

Now, I can use git cherry-pick to pluck out my commits one by one:
cd ../mine  //change to mine/
git log  //shows all my commits and their corresponding SHA, actually
I output the log into a text file so that I can refer to later
cd ../partner
git cherry-pick my_first_commit_sha
//if no conflict, my first commit in mine/ directory is merged into my
partner's work and is committed already!!!
//if there is conflict, then:
git status .  //found out which file(s) were affected by the cherry-
pick merge and which of them are in conflict, then use file editor to
open the files in conflict and edit them, then check them in
git commit -a -m merged from my first commit; solved the conflicts
//Done!

Another way is just merging my commit into my partner's files to
become local changes for me to view, before I commit the merged
results into repository is git format-patch method, which works for me
in one scenario, fails in another scenario. I don't know why:
//at partner directory
git format-patch -1 my_first_commit_sha //-1 is minus one, not
minus little; the command generates a patch file
xxx-xxx-xaskada-adafja.patch //patch file generated
git apply xxx-xxx-xaskada-adafja.patch

//Now, my commit in mine/ has become the local changes in partner/.
Again, if no conflict, then it is ready for commit; if there is
conflicts, need to solve the conflict first, then commit

I have to say, comparing to subversion, git indeed has some
advantages(e.g. everything, including the repository, is inside my
local directory, so no network to the central repository is needed, so
all the commands are fast). For subversion, commit and update commands
are talking with the central repository through the network. When the
project is big, the commands are slow.

However, most--i intend to say all-- git tutotials are half-baked,
including some well-cited tutorials. It seems nobody has the patience
to write it down and show other people and just let other people--like
me-- to struggle and find their way out.



On Oct 14, 8:02 pm, Wes Freeman freeman@gmail.com wrote:
 I might be wrong, so be careful (you should make a copy of both repos
 before you start, just in case), but I think something like this might
 work:

 1. Add your repository as a remote to the new repository.
 2. Pull your changes in to the new repository.
 3. From the new repository, git cherry-pick each commit.

 Wes

 On Fri, Oct 14, 2011 at 3:44 PM, www xs...@yahoo.com wrote:
  Dear All:

  I am new to git and I am using linux.

  I am working on my project, using git and I have made about 20
  commits. All my files are at the directory mine/ Inside mine, there
  is .git directory. Now, I received the tar files from my partner. He
  just finished his part of work and we are working on the same set of
  files. He does not use version control. I put all his files in the
  parallel directory his/. I did the following:

  cd his
  git init
  git add   //all the stuff
  git commit . -m received from partner and he has finished his part

  Ideally, I want to step by step merge my revision one, my revision
  two, my revision three, etc  from mine/ into his/

  It is very likely that there will be conflicts since we are touching
  same files. So I want to do merging step by step. I hope to view each
  revision modification before committing.

  How can I do it? I have googled and studied the whole day and my brain
  hurts.

  Thank you very, very much.

  --
  You received this message because you are subscribed to the Google Groups 
  Git for human beings group.
  To post to this group, send email to git-users@googlegroups.com.
  To unsubscribe from this group, send email to 
  git-users+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/git-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to 

[git-users] Re: How to merge two independent projects one commit by one commit?

2011-10-18 Thread www
Just adding one more point: if during git cherry-pick, there are
conflicts and I found that merge is too messy and complicated. I want
to give up and back to the state before doing git cherry-pick, I
used this command:

git reset --hard HEAD

http://book.git-scm.com/4_undoing_in_git_-_reset,_checkout_and_revert.html

On Oct 18, 12:45 pm, www xs...@yahoo.com wrote:
 Thank you. I have accomplished my goal successfully. Following is what
 I did:

 Again, I have all my work I did. It is located in the directory
 mine/ and I use git to version control all my work. I received the
 work files from my partner. He does not use any version control. He
 sent me his tar files. Both he amd me are working on the same files. I
 un-tar my partner's tar files into the directory partner/, which is
 parralel with mine/.

 cd partner
 git init //create an empty git version control repository
 git add xxx //adding the files into repository
 git commit -a -m received files from my partner. He has finished his
 part

 //Now, I want to merge my work(my commits inside mine/, one by one) to
 my partner's work
 //still at the same location as above
 git remote add my_work ../mine
 git fetch my_work  //fetch all my commits into the remote branch
 my_work
 git branch -a //-a shows all branches
 //shows the following:
 * master
   remotes/my_work/master
 git branch -r //-r shows remote branche
 //shows the following:
   my_work/master

 Now, I can use git cherry-pick to pluck out my commits one by one:
 cd ../mine  //change to mine/
 git log  //shows all my commits and their corresponding SHA, actually
 I output the log into a text file so that I can refer to later
 cd ../partner
 git cherry-pick my_first_commit_sha
 //if no conflict, my first commit in mine/ directory is merged into my
 partner's work and is committed already!!!
 //if there is conflict, then:
 git status .  //found out which file(s) were affected by the cherry-
 pick merge and which of them are in conflict, then use file editor to
 open the files in conflict and edit them, then check them in
 git commit -a -m merged from my first commit; solved the conflicts
 //Done!

 Another way is just merging my commit into my partner's files to
 become local changes for me to view, before I commit the merged
 results into repository is git format-patch method, which works for me
 in one scenario, fails in another scenario. I don't know why:
 //at partner directory
 git format-patch -1 my_first_commit_sha //-1 is minus one, not
 minus little; the command generates a patch file
 xxx-xxx-xaskada-adafja.patch //patch file generated
 git apply xxx-xxx-xaskada-adafja.patch

 //Now, my commit in mine/ has become the local changes in partner/.
 Again, if no conflict, then it is ready for commit; if there is
 conflicts, need to solve the conflict first, then commit

 I have to say, comparing to subversion, git indeed has some
 advantages(e.g. everything, including the repository, is inside my
 local directory, so no network to the central repository is needed, so
 all the commands are fast). For subversion, commit and update commands
 are talking with the central repository through the network. When the
 project is big, the commands are slow.

 However, most--i intend to say all-- git tutotials are half-baked,
 including some well-cited tutorials. It seems nobody has the patience
 to write it down and show other people and just let other people--like
 me-- to struggle and find their way out.

 On Oct 14, 8:02 pm, Wes Freeman freeman@gmail.com wrote:

  I might be wrong, so be careful (you should make a copy of both repos
  before you start, just in case), but I think something like this might
  work:

  1. Add your repository as a remote to the new repository.
  2. Pull your changes in to the new repository.
  3. From the new repository, git cherry-pick each commit.

  Wes

  On Fri, Oct 14, 2011 at 3:44 PM, www xs...@yahoo.com wrote:
   Dear All:

   I am new to git and I am using linux.

   I am working on my project, using git and I have made about 20
   commits. All my files are at the directory mine/ Inside mine, there
   is .git directory. Now, I received the tar files from my partner. He
   just finished his part of work and we are working on the same set of
   files. He does not use version control. I put all his files in the
   parallel directory his/. I did the following:

   cd his
   git init
   git add   //all the stuff
   git commit . -m received from partner and he has finished his part

   Ideally, I want to step by step merge my revision one, my revision
   two, my revision three, etc  from mine/ into his/

   It is very likely that there will be conflicts since we are touching
   same files. So I want to do merging step by step. I hope to view each
   revision modification before committing.

   How can I do it? I have googled and studied the whole day and my brain
   hurts.

   Thank you very, very much.

   --
   You received this message because you are 

Re: [git-users] Re: How to merge two independent projects one commit by one commit?

2011-10-18 Thread Konstantin Khomoutov
On Tue, 18 Oct 2011 05:45:01 -0700 (PDT)
www xs...@yahoo.com wrote:

[...]
 However, most--i intend to say all-- git tutotials are half-baked,
 including some well-cited tutorials. It seems nobody has the patience
 to write it down and show other people and just let other people--like
 me-- to struggle and find their way out.
I beg to differ: you faced a quite unusual situation which is unlikely
to happen to other users--let alone those who spend their time writing
tutorials.  And tutorials are written for people having little to none
knowledge about the topic so they naturally tend to discuss ubiquitous
use cases, in simple terms, and possibly referring to as little Git
tools as possible.

You referred to Subversion here for some reason... do you care to
sketch how would you accomplish the same task with it (and don't forget
that subversion grew `svn patch` command only in version 1.7 which came
just a couple of days ago).  But OK, I think what would be really
useful in this case is you writing a blog post with detailed
description of your problem and the solution to it so that the next guy
could google it (or we could send it straight to your post).

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Re: How to merge two independent projects one commit by one commit?

2011-10-18 Thread www
Alright, I agree with you. Thank you for the tip svn patch.

May I ask you one more question just for my learning purpose? If I ask
my partner who works in a different company also use git, when he
sends me the files he modified and together with .git/ directory. I
can put all his files AND .git under partner/ directory. Then I can
have his commits one by one. Is that correct?

Thank you.

On Oct 18, 1:45 pm, Konstantin Khomoutov
flatw...@users.sourceforge.net wrote:
 On Tue, 18 Oct 2011 05:45:01 -0700 (PDT)

 www xs...@yahoo.com wrote:

 [...] However, most--i intend to say all-- git tutotials are half-baked,
  including some well-cited tutorials. It seems nobody has the patience
  to write it down and show other people and just let other people--like
  me-- to struggle and find their way out.

 I beg to differ: you faced a quite unusual situation which is unlikely
 to happen to other users--let alone those who spend their time writing
 tutorials.  And tutorials are written for people having little to none
 knowledge about the topic so they naturally tend to discuss ubiquitous
 use cases, in simple terms, and possibly referring to as little Git
 tools as possible.

 You referred to Subversion here for some reason... do you care to
 sketch how would you accomplish the same task with it (and don't forget
 that subversion grew `svn patch` command only in version 1.7 which came
 just a couple of days ago).  But OK, I think what would be really
 useful in this case is you writing a blog post with detailed
 description of your problem and the solution to it so that the next guy
 could google it (or we could send it straight to your post).

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: How to merge two independent projects one commit by one commit?

2011-10-18 Thread Konstantin Khomoutov
On Tue, 18 Oct 2011 07:17:39 -0700 (PDT)
www xs...@yahoo.com wrote:

 May I ask you one more question just for my learning purpose? If I ask
 my partner who works in a different company also use git, when he
 sends me the files he modified and together with .git/ directory. I
 can put all his files AND .git under partner/ directory. Then I can
 have his commits one by one. Is that correct?
Don't to that.  If there's absolutely no way for you to have network
connectivity betweeen your machines and there's no way for both of you
to access a central repo (on a specialized public Git hosting or VPS),
then consider using `git bundle` which was designed specifically for
this sort of things.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.