how git pull works?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 --
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]