Re: [git-users] git branch : strange !
> From: djsuperfive > Why do I have a change to add on master whereas I made this change on my > branch "dev" ? I think I can explain this more clearly: You changed a file, but since you didn't add or commit it, none of the branches is affected. git-status is just telling you that the file index.php that is in the working directory isn't the same as the one in the index (and the one in the index is the same as the head of the current branch). Now you tell Git to switch to a new branch. Git adjusts the internal data structures, of course, but it also has to adjust all the files in the working directory to match the new branch head. What is it to do with the changed file in the working directory? In general, it leaves it alone, so you don't lose your changes. In specific, if the version of that file is different in the two branches, Git tries to merge the inter-branch changes with the changes you've inserted; it can get messy. As far as I can tell, Git does a similar update process on the index, whose contents may not have been the same as the old branch's head. This leads to a situation you might not expect: Suppose you have branch master checked out. Now change index.php to be the same as the version in the head of branch dev. git-status will show it as being modified. Now check out branch dev. If I have it right, Git will merge the change it sees in the working copy of index.php with the inter-branch change (both of which are the same) to leave a copy of index.php which matches the head of branch dev. git-status will now show index.php as not being modified. Now check out branch master. index.php isn't modified any more! Dale -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] git branch : strange !
Hi, git doesn's save changes in a branch. Only commits are saved in an specific branch. So, if you have a change in a file and change the branch, this change will be at the new branch. If you don't want it, you need to commit or stash the change before changing branch. If changing a branch will cause a conflict of a modified file with a change in the branch that you want to change, Git you tell you that you need to commit before changing the branch. William Seiti Mizuta @williammizuta Caelum | Ensino e Inovação www.caelum.com.br On Fri, Aug 30, 2013 at 12:21 PM, djsuperfive wrote: > Hi ! > > I'm learning git and have a strange issue with a simple branch scenario: > > I created a new local branch "dev". > So now I have two local branches: master and dev.On master, everything > isup to date: nothing to add, nothing to commit. > > I've checked out the branch "dev" and made a change in one file. I haven't > committed anything yet after this change. > A git status tells me: > # On branch dev > # Changes not staged for commit: > # (use "git add ..." to update what will be committed) > # (use "git checkout -- ..." to discard changes in working > directory) > # > # modified: index.php > # > no changes added to commit (use "git add" and/or "git commit -a") > > Now I go back to "master" (git checkout master), and a "git status" tell > me the following: > # On branch master > # Changes not staged for commit: > # (use "git add ..." to update what will be committed) > # (use "git checkout -- ..." to discard changes in working > directory) > # > # modified: index.php > # > no changes added to commit (use "git add" and/or "git commit -a") > > Why do I have a change to add on master whereas I made this change on my > branch "dev" ? > > What do you think ? > > -- > You received this message because you are subscribed to the Google Groups > "Git for human beings" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to git-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] git branch : strange !
Hello, braches hold only commited changes (actually, they are pointers to one specific commit). Uncommited changes "travel" between checkouts (well, unless the target branch is in a totally different state, as then you will face even stranger merge issues). So take this advise: never checkout another branch without commiting/reverting your changes! Cheers, Gergely On 30 Aug 2013 17:22, "djsuperfive" wrote: > Hi ! > > I'm learning git and have a strange issue with a simple branch scenario: > > I created a new local branch "dev". > So now I have two local branches: master and dev.On master, everything > isup to date: nothing to add, nothing to commit. > > I've checked out the branch "dev" and made a change in one file. I haven't > committed anything yet after this change. > A git status tells me: > # On branch dev > # Changes not staged for commit: > # (use "git add ..." to update what will be committed) > # (use "git checkout -- ..." to discard changes in working > directory) > # > # modified: index.php > # > no changes added to commit (use "git add" and/or "git commit -a") > > Now I go back to "master" (git checkout master), and a "git status" tell > me the following: > # On branch master > # Changes not staged for commit: > # (use "git add ..." to update what will be committed) > # (use "git checkout -- ..." to discard changes in working > directory) > # > # modified: index.php > # > no changes added to commit (use "git add" and/or "git commit -a") > > Why do I have a change to add on master whereas I made this change on my > branch "dev" ? > > What do you think ? > > -- > You received this message because you are subscribed to the Google Groups > "Git for human beings" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to git-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.