2009/3/27 James Byrne <[email protected]>

>
> ..
>
> 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")
> $


This is because you had not committed the change to y.rb. A checkout will
not overwrite modified (uncommitted) files. You should have seen a message
when you switched to the master warning that y was modified (M  filename).
You will think this is the optimum behaviour the when you forget to commit
before a switch.


>
> 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.


The master has not been affected, it is just the modified file left there.


>
>
> 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:
>

I do not understand how x.rb had disappeared from the master, you should see
the original x.rb.  If x.rb was a new file on the branch then you would
expect it to be missing from the master.

Colin


>
> $ 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