# 准备:echo0>fgitaddfgitcommit-m'0'# On branch master# Changes not staged for commit:# (use "git add/rm <file>..." to update what will be committed)# (use "git restore <file>..." to discard changes in working directory)# deleted: dir/name.ext# deleted: dir/name2.ext## Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## no changes added to commit (use "git add" and/or "git commit -a")echo1>fgitaddfecho2>f# 执行:gitrestore--sourceHEAD--worktree--f# 检查:gitcat-fileblob $(gitls-files-s--f|awk'{ print $2; }')# 1catf# 0
利用tree同时更新index和worktree
Lv2 一步一步来即可
Lv3
# 准备:echo0>fgitaddfgitcommit-m'0'# On branch master# Changes not staged for commit:# (use "git add/rm <file>..." to update what will be committed)# (use "git restore <file>..." to discard changes in working directory)# deleted: dir/name.ext# deleted: dir/name2.ext## Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## no changes added to commit (use "git add" and/or "git commit -a")echo1>fgitaddfecho2>f# 执行:gitrestore--sourceHEAD--staged--worktree--f# 检查:gitcat-fileblob $(gitls-files-s--f|awk'{ print $2; }')# 0catf# 0
gitstatus# On branch master# Changes not staged for commit:# (use "git add/rm <file>..." to update what will be committed)# (use "git restore <file>..." to discard changes in working directory)# deleted: dir/name.ext# deleted: dir/name2.ext## Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## no changes added to commit (use "git add" and/or "git commit -a")gitstash# Saved working directory and index state WIP on master: 5e2ea31 0gitstatus# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## nothing added to commit but untracked files present (use "git add" to track)gitstashpop# Removing dir/name2.ext# Removing dir/name.ext# On branch master# Changes not staged for commit:# (use "git add/rm <file>..." to update what will be committed)# (use "git restore <file>..." to discard changes in working directory)# deleted: dir/name.ext# deleted: dir/name2.ext## Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## no changes added to commit (use "git add" and/or "git commit -a")# Dropped refs/stash@{0} (d6ae6279a658b60a3a396fc2db675fcd84dcdb14)gitstatus# On branch master# Changes not staged for commit:# (use "git add/rm <file>..." to update what will be committed)# (use "git restore <file>..." to discard changes in working directory)# deleted: dir/name.ext# deleted: dir/name2.ext## Untracked files:# (use "git add <file>..." to include in what will be committed)# -funame.ext# -funame2.ext# .bashrc# .gitconfig# .profile# dir/fn## no changes added to commit (use "git add" and/or "git commit -a")
touchextra# 检查多出来了什么文件gitclean-nd# Would remove -funame.ext# Would remove -funame2.ext# Would remove .bashrc# Would remove .gitconfig# Would remove .profile# Would remove dir/fn# Would remove extra# 统统删掉gitclean-fd# Removing -funame.ext# Removing -funame2.ext# Removing .bashrc# Removing .gitconfig# Removing .profile# Removing dir/fn# Removing extra
echo'fff'>.gitignoregitadd.gitignoretouchffftouchextra# 准备删掉多出来的non-ignored文件gitclean-nd# Would remove extra# 准备删掉多出来的所有文件gitclean-ndx# Would remove extra# Would remove fff# 准备删掉多出来的ignored文件gitclean-ndX# Would remove fff