Wednesday, March 31, 2010

git clean

With git, you can reset your working directory to a pristine checkout

$ git clean -xdn

to see what's going to be done, followed by

$ git clean -xdf


-x means even kill ignored files
-d means remove untracked directories as well as files
-n means dry run: tell me what you're going to do
-f means force: actually do it!

Tuesday, March 16, 2010

rsync command that makes two things the same

To update a copy of something:

$ rsync --archive --delete --hard-links --verbose --progress --dry-run SOURCE DESTINATION

this performs deletes (--dry-run to see what first!)

Note that the  syntax is sensitive to trailing slashes on the source:

To back up /home to a directory on an external drive, you probably want:

sudo rsync --archive --delete --hard-links --progress --dry-run /home/ /mnt/wdexternal/woc-desktop/home

as the command without the slash after /home/ will create a new subdirectory /mnt/wdexternal/woc-desktop/home/home

the short version has -avH for archive, verbose, hard-links.
delete, progress and dry-run appear to only be long options

verbose tells you what's being copied, progress gives you percentage copied so far for large files

quite often what I want is to backup a subtree in my home directory

$ rsync -avH dir/ old-dir

does the business in this case