Ecco un esempio breve frammento (che è possibile incollare nel terminale Linux), creando un nuovo git
repository e l'aggiunta di alcuni file ad esso (usando git versione 1.7.9.5):Lo stato git mostra file di tracciati non modificati/non modificati?
cd /tmp/
mkdir myrepo_git
cd myrepo_git/
git init
git config user.name "Your Name"
git config user.email [email protected]
echo "test" > file_tracked_unchanged.txt
echo "test" > file_tracked_changed.txt
echo "test" > file_untracked.txt
git add file_tracked_unchanged.txt
git add file_tracked_changed.txt
git commit -m "initial commit"
Ora, dopo la commit iniziale, voglio cambiare i file file_tracked_changed.txt
e mantenere gli altri (qui, solo file_tracked_unchanged.txt
) invariato per il prossimo commit. Di seguito è riportato un frammento che dimostra che, e le diverse uscite di git status
vs git ls-files
(git
uscita shell è preceduto da #
):
echo "test more" >> file_tracked_changed.txt
git status -uno
# # On branch master
# # 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: file_tracked_changed.txt
# #
# no changes added to commit (use "git add" and/or "git commit -a")
git status
# # On branch master
# # 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: file_tracked_changed.txt
# #
# # Untracked files:
# # (use "git add <file>..." to include in what will be committed)
# #
# # file_untracked.txt
# no changes added to commit (use "git add" and/or "git commit -a")
git status -uno --short
# M file_tracked_changed.txt
git status --short
# M file_tracked_changed.txt
# ?? file_untracked.txt
git ls-files -v
# H file_tracked_changed.txt
# H file_tracked_unchanged.txt
git add file_tracked_changed.txt
git status -uno
# # On branch master
# # Changes to be committed:
# # (use "git reset HEAD <file>..." to unstage)
# #
# # modified: file_tracked_changed.txt
# #
# # Untracked files not listed (use -u option to show untracked files)
git status
# # On branch master
# # Changes to be committed:
# # (use "git reset HEAD <file>..." to unstage)
# #
# # modified: file_tracked_changed.txt
# #
# # Untracked files:
# # (use "git add <file>..." to include in what will be committed)
# #
# # file_untracked.txt
git status -uno --short
# M file_tracked_changed.txt
git status --short
# M file_tracked_changed.txt
# ?? file_untracked.txt
git ls-files -v
# H file_tracked_changed.txt
# H file_tracked_unchanged.txt
Quello che sto cercando, è un comando che mostrerà tutti i file monitorati in una directory (che fa git ls-files -v
), con il loro stato di repository accurato (che non viene mostrato da git ls-files
, poiché mostra lo stato H
come stato per tutti i file tracciati). Per esempio, mi piacerebbe per ottenere qualcosa di simile al pseudocodice:
git status-tracked
# M file_tracked_changed.txt
# . file_tracked_unchanged.txt
... dove il punto .
sarebbe un simbolo che indica un monitorati, ma file non modificato (se non ricordo male, SVN può utilizzare un carattere U
per questi).
In definitiva, mi piacerebbe mostrare anche lo stato di tutti i file in una directory, come nel pseudocodice:
git status-tracked-and-untracked
# M file_tracked_changed.txt
# . file_tracked_unchanged.txt
# ?? file_untracked.txt
... ma è più importante per me per raggiungere lo stato di tutti file tracciati, come nella precedente pseudo git status-tracked
.
Qualsiasi comando in git
, che già fa qualcosa di simile?
Prova 'git status -sb' – Kartik
Molte grazie per il commento @Kartik - ma quel comando mostra tracked modified + untracked; Sto cercando un comando che mostri tracciato modificato + tracciato non modificato. Saluti! – sdaau