Suggestion: make git checkout safer

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

 



Currently a plain 'git checkout .' will revert any local changes, e.g.

    % mkdir test
    % cd test
    % git init
    Initialized empty Git repository in /home/eda/test/.git/
    % echo hello >foo
    % git add foo
    % git commit -m.
    [master (root-commit) 34f6694] .
     1 file changed, 1 insertion(+)
     create mode 100644 foo
    % echo goodbye >foo
    % git checkout .
    % cat foo
    hello

I suggest this is dangerous and by default 'git checkout' should only alter
files which do not have local changes (as would be reported by 'git diff').
Only if --force is given should working tree differences be thrown away.

    % git --version
    git version 2.4.0

-- 
Ed Avis <eda@xxxxxxxxxxxxx>

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