Often I move files in a git repository using my IDE or via the command line (not via git mv).
As a result I and end up with several unstaged files to be deleted on my next commit as below:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: test.html
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: css/bootstrap.css
# deleted: css/bootstrap.min.css
# deleted: img/glyphicons-halflings-white.png
# deleted: img/glyphicons-halflings.png
# deleted: js/bootstrap.js
# deleted: js/bootstrap.min.js
I typically will select all the deleted files and edit them in a text editor to produce like:
git rm css/bootstrap.css
git rm css/bootstrap.min.css
git rm img/glyphicons-halflings-white.png
git rm img/glyphicons-halflings.png
git rm js/bootstrap.js
git rm js/bootstrap.min.js
Which I then throw back into the console.
Is there a way to do this without having to copy/paste?
If I understand your question correctly, you want to commit your deletes…that is, you want to perform the equivalent of
git rmfor all of the files that show up as deleted.git cleanwon’t do this.You can run
git add -u:This will pick up all changes to tracked files, including deletes. So if you start with this:
Running
git add -uwill get you to this:And a commit at this point will do the right thing.