Remove
To remove from index but keep in working directory, use --cached
#!/bin/sh
: "Removing files from repository
If a file is not tracked rm file will generate error
To remove a file and keep it in working directory, use --cached
To remove a file from working directory, when used with -f
"
alias gs="git status | sed 's/^/\t/' ; echo"
alias gsp="git status --porcelain | sed 's/^/\t/' ; echo"
touch a.tmp
echo 'touch'
gsp
git add a.tmp
echo 'git add'
gsp
git rm -q --cached a.tmp
echo 'git rm --cached'
gsp
git add a.tmp
echo 'git add'
gsp
git rm -fq a.tmp
echo 'git rm -f'
gs
touch
?? main/basics/remove/a.tmp
git add
A main/basics/remove/a.tmp
git rm --cached
?? main/basics/remove/a.tmp
git add
A main/basics/remove/a.tmp
git rm -f
On branch main
nothing to commit, working tree clean
Remove directory
Remove a directory from the Git repository cache and stop tracking it.
git rm -r --cached github/spring-boot
git commit -m "Remove github/spring-boot from tracking"
Last update: 431 days ago