git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dowlin Yang <dowlin0820@gmail.com>
To: git@vger.kernel.org
Subject: how git pull works?
Date: Fri, 19 Nov 2010 23:15:51 +0800	[thread overview]
Message-ID: <4CE3FBA5-3DF0-493F-9600-6D424B5CBA2F@gmail.com> (raw)

Hello

I sent an email earlier but it seems rejected. I resent again with plain text format. I am sorry for any inconvenience if you receive my messages twice, and please read the new one.

We have been using git for a while and it always works like a magic. We have several teammates and each of us may work on one or multiple branches at the same time. Sometimes one person may have to merge another's branch for getting the latest version. We always use git pull origin branch-name to get the remote branch merged and it always works nicely until recently we face a problem that we cannot figure it out. The following is the scenario we faced.

Suppose A had a branch b1 and B had a branch b2. They work on their own branch separately but b1 and b2 share the same file f1. Suppose A made a few changes to f1 on Nov 5th. Here are A's changes:

======= In branch b1, changes that were made by A on Nov 5th


@@ -1,6 +1,6 @@
 <?
 $COMMON_JS = array(

-    'lib/jquery-1.3.2.min.js'
,
+    'lib/jquery-1.4.3.min.js',

     'lib/jquery-ui-1.7.2.
custom.min.js',
     'lib/jquery.metadata.js',

     'lib/jquery.form.js',


@@ -26,6 +26,7 @@ $JS = array(
         'files' => array(
             'com/categories.js',
             'com/searcher.js',

+            'com/category_
bar.js',
             'com/query_refiner.js',

             'com/fast_input.
js',
             'com/subscribe_form.js',    

@@ -50,6 +51,7 @@ $JS = array(
         'files' => array(
             'com/categories.js',
             'com/searcher.js',

+            'com/category_
bar.js',
             'com/product_image_loader.js',                    

             'com/tab_toggle.
js',
             'page.deal.js'
=======

A removed one line and added a few lines to f1 and then committed on Nov 5th. On the other hand, B made a few changes to f1 too on the next day Nov 6th. Here are B's changes:

======= In branch b2, changes that were made by B on Nov 6th



@@ -26,7 +26,6 @@ $JS = array(
         'files' => array(
             'com/categories.js',
             'com/searcher.js',

-            'com/category_
bar.js',
             'com/query_refiner.js',

             'com/fast_input.
js',
             'com/subscribe_form.js',    

@@ -51,7 +50,6 @@ $JS = array(
         'files' => array(
             'com/categories.js',
             'com/searcher.js',

-            'com/category_
bar.js',
             'com/product_image_loader.js',                    

             'com/tab_toggle.
js',
             'page.deal.js'
=======

B removed a few lines and then committed on Nov 6th. They kept updating other files in the following days. After a few days, we decide to merge A's branch b1 with B's branch b2. So A did git pull origin b2 in b1, and the expected resultant file is sth like this:

======== Expected resultant file
 $COMMON_JS = array(
-    'lib/jquery-1.3.2.min.js',

+    'lib/jquery-1.4.3.min.js'
,
     'lib/jquery-ui-1.7.2.custom.min.js',

     'lib/jquery.metadata.js',

     'lib/jquery.form.js',
.....

         'files' => array(

             'com/categories.js',

             'com/searcher.js'
,
-            'com/category_bar.js',

             'com/query_
refiner.js',
             'com/fast_input.js',

             'com/subscribe_
form.js',    

.....
         'files' => array(
             'com/categories.js',

             'com/searcher.js'
,
-            'com/category_bar.js',

             'com/product_
image_loader.js',                    
             'com/tab_toggle.js',

             'page.deal.js'



========

We expect com/category_bar.js will be removed and lib/jquery-1.3.2.min.js will be replaced by lib/jquery-1.4.3.min.js However, it did not work like we expected. Instead, com/category_bar.js are still there, and jquery is replaced. We wonder why it works like this. Aren't newer changes supposed to be applied? Why older changes are the final results? Perhaps we misunderstand git pull? Please enlighten us where we may make any mistake. Else we just feel like we cannot trust git pull. :(

Oh, I forgot to mention one thing in the above scenario. B's b2 branch had com/category_bar.js added earlier than A's b1. A manually added the same changes to b1 on Nov 5th, but later B decided to remove com/category_bar.js from b2 on Nov 6h as I described.

So, is it possible that git assumes com/category_bar.js are added twice and removed once, so it means the final result will be com/category_bar.js is added once? It is not easy to describe the scenario... Any help is appreciated! Thanks very much.

Huiting 

             reply	other threads:[~2010-11-19 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19 15:15 Dowlin Yang [this message]
2010-11-19 15:27 ` how git pull works? Dowlin Yang
2010-11-19 21:27 ` Jan Hudec
2010-11-20  1:18   ` Dowlin Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CE3FBA5-3DF0-493F-9600-6D424B5CBA2F@gmail.com \
    --to=dowlin0820@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).