Friday, May 24, 2013

Useful Git Scripts

Anybody that has worked with me closely knows that I have a bash script for nearly everything I do in the terminal.

I'll put some git related commands here as time permits...

remove-files-from-git-repo-that-have-been-deleted-locally


#!/bin/bash
# Usage: remove-files-from-git-repo-that-have-been-deleted-locally
#
# Stage the removal of the deleted files and then commit
git ls-files --deleted | xargs git rm
git commit -m "remove-files-from-git-repo-that-have-been-deleted-locally"

Other options that are not so great

The following only works for a limited number of file deletions:

$ git rm $(git ls-files --deleted)
-bash: /usr/local/bin/git: Argument list too long


The following will not only stage deletions, but will also add any other file that has been changed and has been previously referenced by git.

git add -u .


The following similar to git add -u ., but it also adds new files.

git add -A

No comments:

Post a Comment