{"thread":{"id":"27436","subject":"git checkout no longer warning about uncommitted/untracked files!","startedAt":"2011-05-23T17:29:57Z","lastAt":"2011-05-23T21:27:51Z","messageCount":8,"participants":["funeeldy","René Scharfe","Jeff King","Marlene Cote"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"168511","messageId":"1306171797211-6395441.post@n2.nabble.com","threadId":"27436","inReplyTo":null,"subject":"git checkout no longer warning about uncommitted/untracked files!","fromName":"funeeldy","fromEmail":"marlene_cote@affirmednetworks.com","sentAt":"2011-05-23T17:29:57Z","receivedAt":"2011-05-23T17:29:57Z","isPatch":false,"sender":{"key":"marlene_cote@affirmednetworks.com","avatar":null},"body":"I found some other posts that seem to indicate that this is the right place\nto file bug reports for git.  If this is wrong, please let me know the\nproper method.\nWe are using git version 1.7.3.  We just noticed that git checkout no longer\nwarns about uncommitted/untracked files and just deletes them!!!  I had a\ndeveloper lose a lot of work today because \nthey were not committing regularly (which they will do now), and because I\ntold them to perform the checkout believing that it would do as it has\nalways done, and warn about their modified and untracked new files.\nI believe this is a bug.  Is it fixed in a later release already?  If so,\nwhich release?  You guys really need to get a bug tracking system like Jira\nto allow the git user community to file bugs and feature requests!!!!\nThanks for your help.\n\n--\nView this message in context: http://git.661346.n2.nabble.com/git-checkout-no-longer-warning-about-uncommitted-untracked-files-tp6395441p6395441.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"168528","messageId":"4DDAC57D.9020809@lsrfire.ath.cx","threadId":"27436","inReplyTo":"1306171797211-6395441.post@n2.nabble.com","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2011-05-23T20:37:17Z","receivedAt":"2011-05-23T20:37:17Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 23.05.2011 19:29, schrieb funeeldy:\n> I found some other posts that seem to indicate that this is the right place\n> to file bug reports for git.  If this is wrong, please let me know the\n> proper method.\n> We are using git version 1.7.3.  We just noticed that git checkout no longer\n> warns about uncommitted/untracked files and just deletes them!!!\n\nI can't reproduce this behaviour based on this description alone:\n\n\t$ git --version\n\tgit version 1.7.3\n\t$ uname -a\n\tLinux ubuntu 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux\n\n\t$ mkdir /tmp/repo && cd /tmp/repo\n\t$ git init\n\tInitialized empty Git repository in /tmp/repo/.git/\n\t$ git config -l\n\tcolor.ui=auto\n\tuser.name=René Scharfe\n\tuser.email=rene.scharfe@lsrfire.ath.cx\n\tcore.repositoryformatversion=0\n\tcore.filemode=true\n\tcore.bare=false\n\tcore.logallrefupdates=true\n\n\t$ echo 1 >a\n\t$ git add a\n\t$ git commit -m.\n\t[master (root-commit) b0e60d3] .\n\t 1 files changed, 1 insertions(+), 0 deletions(-)\n\t create mode 100644 a\n\n\t$ git branch x\n\t$ echo uncommitted >a\n\t$ echo untracked >b\n\n\t$ git checkout x\n\tM\ta\n\tSwitched to branch 'x'\n\n\t$ cat a\n\tuncommitted\n\t$ cat b\n\tuntracked\n\nCan you reconstruct what your colleague did, perhaps using his or\nher shell's command history file (e.g. ~/.bash_history)?\n"},{"id":"168530","messageId":"1306184704408-6396225.post@n2.nabble.com","threadId":"27436","inReplyTo":"1306171797211-6395441.post@n2.nabble.com","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"funeeldy","fromEmail":"marlene_cote@affirmednetworks.com","sentAt":"2011-05-23T21:05:04Z","receivedAt":"2011-05-23T21:05:04Z","isPatch":false,"sender":{"key":"marlene_cote@affirmednetworks.com","avatar":null},"body":"This is with version 1.7.5.2 - it just keeps the files as modified when I\ncheckout a different branch.  The bad thing about this is that if I make a\nchange on both branches, only the last change is kept, silently.\nEarlier today when I tried this new version, the first checkout failed with\nthe error message I expected, but I cannot get it to show me that again.\n\nprivate/marlene_cote/test/anroot/projects/kernel main_int $ git st\n# On branch main_int\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working\ndirectory)\n#\n#\tmodified:   Makefile\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n/private/marlene_cote/test/anroot/projects/kernel main_int $ git checkout\nmain\nM\tMakefile\nBranch main set up to track remote branch main from origin.\nSwitched to a new branch 'main'\n/private/marlene_cote/test/anroot/projects/kernel main $ git checkout\nmain_int\nM\tMakefile\nSwitched to branch 'main_int'\n/private/marlene_cote/test/anroot/projects/kernel main_int $ git checkout\nmain\nM\tMakefile\nSwitched to branch 'main'\nv/private/marlene_cote/test/anroot/projects/kernel main $ vi Makefile \n/private/marlene_cote/test/anroot/projects/kernel main $ git checkout\nmain_int\nM\tMakefile\nSwitched to branch 'main_int'\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/git-checkout-no-longer-warning-about-uncommitted-untracked-files-tp6395441p6396225.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"168531","messageId":"20110523211042.GC6281@sigill.intra.peff.net","threadId":"27436","inReplyTo":"4DDAC57D.9020809@lsrfire.ath.cx","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-05-23T21:10:42Z","receivedAt":"2011-05-23T21:10:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 23, 2011 at 10:37:17PM +0200, René Scharfe wrote:\n\n> \t$ echo 1 >a\n> \t$ git add a\n> \t$ git commit -m.\n> \t[master (root-commit) b0e60d3] .\n> \t 1 files changed, 1 insertions(+), 0 deletions(-)\n> \t create mode 100644 a\n> \n> \t$ git branch x\n> \t$ echo uncommitted >a\n> \t$ echo untracked >b\n> \n> \t$ git checkout x\n> \tM\ta\n> \tSwitched to branch 'x'\n\nBut you're not actually switching trees here, so there is by definition\nno merge that needs to happen, and the changes stay in place.\n\n> \t$ cat a\n> \tuncommitted\n> \t$ cat b\n> \tuntracked\n\nAnd here, there is no contention over \"b\" since git would never need to\nwrite it at all.\n\nA better test would be:\n\n  git init repo && cd repo\n  echo 1 >a && git add a && git commit -m a1\n  echo 2 >a && git add a && git commit -m a2\n\n  git checkout -b check-uncommitted master^\n  # should fail because we would have to merge\n  echo 3 >a && git checkout master\n\n  git checkout -f master\n  echo 4 >b && git add b && git commit -m b4\n  git checkout -b check-untracked master^\n  echo untracked >b\n  # should fail because we would overwrite untracked b\n  git checkout master\n\nAnd indeed, testing with v1.7.3., both of my \"should fail\" checkouts do\nfail, with the following messages respectively:\n\n  error: Your local changes to the following files would be overwritten by checkout:\n        a\n  Please, commit your changes or stash them before you can switch branches.\n  Aborting\n\nand\n\n  error: The following untracked working tree files would be overwritten by checkout:\n        b\n  Please move or remove them before you can switch branches.\n  Aborting\n\nSo I still don't know what the bug is.\n\n-Peff\n"},{"id":"168532","messageId":"1306185443823-6396282.post@n2.nabble.com","threadId":"27436","inReplyTo":"1306184704408-6396225.post@n2.nabble.com","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"funeeldy","fromEmail":"marlene_cote@affirmednetworks.com","sentAt":"2011-05-23T21:17:23Z","receivedAt":"2011-05-23T21:17:23Z","isPatch":false,"sender":{"key":"marlene_cote@affirmednetworks.com","avatar":null},"body":"Is there any way a checkout would not warn about modified and untracked\nfiles, and then proceed to lose them all? \n\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/git-checkout-no-longer-warning-about-uncommitted-untracked-files-tp6395441p6396282.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"168533","messageId":"20110523211826.GD6281@sigill.intra.peff.net","threadId":"27436","inReplyTo":"1306184704408-6396225.post@n2.nabble.com","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-05-23T21:18:26Z","receivedAt":"2011-05-23T21:18:26Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 23, 2011 at 02:05:04PM -0700, funeeldy wrote:\n\n> This is with version 1.7.5.2 - it just keeps the files as modified when I\n> checkout a different branch.\n\nRight. This has always been the way git works.\n\n> The bad thing about this is that if I make a change on both branches,\n> only the last change is kept, silently.\n\nNo, in the example below, you don't actually make a change on a branch.\nYou make a change to your _worktree_, but that change is not associated\nwith a branch until you actually commit (which you never do in your\nexample).\n\n> private/marlene_cote/test/anroot/projects/kernel main_int $ git st\n> # On branch main_int\n> # Changed but not updated:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working\n> directory)\n> #\n> #\tmodified:   Makefile\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nOK, so you have a change to your Makefile...\n\n> /private/marlene_cote/test/anroot/projects/kernel main_int $ git checkout\n> main\n> M\tMakefile\n> Branch main set up to track remote branch main from origin.\n> Switched to a new branch 'main'\n\nAnd now you switch to another branch. Because the version of Makefile in\n\"main\" is the same as the one on \"main_int\", git can switch branches and\npreserve your worktree change (if there had been a change to Makefile in\nmain_int, you would have seen an error, and git would have told you to\ncommit or stash your change sfirst).\n\n> /private/marlene_cote/test/anroot/projects/kernel main $ git checkout\n> main_int\n> M\tMakefile\n> Switched to branch 'main_int'\n\nNow you're back on main_int, but again, you still have the same change\nin Makefile in your worktree.\n\n> /private/marlene_cote/test/anroot/projects/kernel main_int $ git checkout\n> main\n> M\tMakefile\n> Switched to branch 'main'\n\nAnd back to main, with the same change in the worktree.\n\n> v/private/marlene_cote/test/anroot/projects/kernel main $ vi Makefile \n\nAnd now you edit the Makefile to new content. If you are expecting the\nintermediate state of the Makefile to be kept, it is not. You never\ncommitted it.\n\n> /private/marlene_cote/test/anroot/projects/kernel main $ git checkout\n> main_int\n> M\tMakefile\n> Switched to branch 'main_int'\n\nAnd you still have the new content, because none of these checkouts is\nchanging your Makefile at all; you are just switching other files around\nwhile the same changes to Makefile sit in the worktree.\n\n-Peff\n"},{"id":"168534","messageId":"20110523211857.GE6281@sigill.intra.peff.net","threadId":"27436","inReplyTo":"1306185443823-6396282.post@n2.nabble.com","subject":"Re: git checkout no longer warning about uncommitted/untracked files!","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-05-23T21:18:58Z","receivedAt":"2011-05-23T21:18:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 23, 2011 at 02:17:23PM -0700, funeeldy wrote:\n\n> Is there any way a checkout would not warn about modified and untracked\n> files, and then proceed to lose them all? \n\nGit checkout -f ?\n\n-Peff\n"},{"id":"168537","messageId":"1F026B57884A5841B330471696849DE904C083@MBX021-W4-CA-5.exch021.domain.local","threadId":"27436","inReplyTo":"20110523211857.GE6281@sigill.intra.peff.net","subject":"RE: git checkout no longer warning about uncommitted/untracked files!","fromName":"Marlene Cote","fromEmail":"marlene_cote@affirmednetworks.com","sentAt":"2011-05-23T21:27:51Z","receivedAt":"2011-05-23T21:27:51Z","isPatch":false,"sender":{"key":"marlene_cote@affirmednetworks.com","avatar":null},"body":"Yes, we didn't use -f .\n\n--------------------------\nRegards,\nMarlene Cote\nAffirmed Networks\n978-268-0821 \n\n\n\n->-----Original Message-----\n->From: Jeff King [mailto:peff@peff.net]\n->Sent: Monday, May 23, 2011 5:19 PM\n->To: Marlene Cote\n->Cc: git@vger.kernel.org\n->Subject: Re: git checkout no longer warning about uncommitted/untracked files!\n->\n->On Mon, May 23, 2011 at 02:17:23PM -0700, funeeldy wrote:\n->\n->> Is there any way a checkout would not warn about modified and untracked\n->> files, and then proceed to lose them all?\n->\n->Git checkout -f ?\n->\n->-Peff\n"}]}