I have been using Git for about a year now, but always in the master
branch.  I decided to try working in a branch to get experience with
merging. Naturally enough, I am now observing some behaviour that I do
not understand.  I would appreciate any explanation of what is happening
and whether this is expected behaviour or not.

I initially pull from the remote repository and then checkout -b
workcopy from the master.  At this point workcopy and master are
identical.  In workcopy I modify x.rb and y.rb.  I then add/commit x.rb
in workcopy.  Next I checkout back to master.

>From what i had read about git I believed that all the modifications
that I made to x and y in workcopy only affectedi workcopy; and that
those files in the master branch were still pristine as when they had
been pulled.  However, when I checkouted the master branch this is what
I saw:

$ git co master
M y.rb
Switched to branch master
$
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   y.rb
no changes added to commit (use "git add" and/or "git commit -a")
$

A git diff on y.rb in both branches produced identical output. This
clearly indicates that the changes that I made in the working branch
affected the master branch too.  This is something that I thought not
possible.  Was I wrong in my belief or am I doing something wrong in my
implementation.

Further, I noted that x.rb had disappeared from view on the master even
though it had only been commited on the workcopy branch.  However, when
I ran merge on the master then I saw this:

$ git merge workcopy
Updating bb48bcc..339ec9a
y.rb: needs update
Fast forward

 ...x.rb                                            |    3 +
 1 file changed, 3 insertions(+), 0 deletions(-)
$

I am somewhat confused by this behaviour.  If what I do in a branch but
do not commit impacts the master while changes commited in the branch
simply disappear from view in the master then what is the advantage to
branching?  What am I doing wrong?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to