Esecuzione di Windows 7 con Git installato da Git-1.8.3-preview20130601.exe
.git checkout non ripristina il file
Ho un file modificato nella mia directory di lavoro, mi piacerebbe ripristinarlo al suo stato all'ultimo commit. Ho provato varie invocazioni di git checkout
, ma il file modificato rimane nella mia directory di lavoro. Per esempio:
[C:\Work\BitBucket\proj1] 14:32:45>git status
On branch work2
Your branch is behind 'origin/work2' by 9 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: pomodoro.html
no changes added to commit (use "git add" and/or "git commit -a")
[C:\Work\BitBucket\proj1] 14:32:53>git checkout pomodoro.html
[C:\Work\BitBucket\proj1] 14:33:00>git status
On branch work2
Your branch is behind 'origin/work2' by 9 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: pomodoro.html
no changes added to commit (use "git add" and/or "git commit -a")
[C:\Work\BitBucket\proj1] 14:33:04>
(ottengo lo stesso risultato con git checkout -- pomodoro.html
.)
Quindi, git pensa pomodoro.html viene modificato, ma quando uso
git difftool
Mi hanno detto che il i file sono identici.
Non so se è rilevante, ma ho core.autocrlf
impostato su true
nella mia configurazione Git. Quando l'ho cambiato in false
ho avuto lo stesso comportamento, però.
@MarkusUnterwaditzer Ci ha provato. – millimoose
'git checkout pomodoro.html' controllerà il file dall'indice, non da un commit - questo potrebbe essere il colpevole se hai già aggiunto le modifiche. Per * ripristinare * un file, proverei 'git checkout HEAD pomodoro.html'. – millimoose
@millimoose: Non ho eseguito le modifiche, voglio solo annullare le modifiche non modificate. "git checkout HEAD pomodoro.html" non ha funzionato, o ... – Number8