Q:

Version control a file from directory only when I ask, rather than initial full commit for entire directory?

Could I put a certain file in some VCS like git/subversion/etc only "when" I am  modifying it. So first I put the unmodified version & then the modified version. The desire is to put the file in VCS only when I want, rather than doing initial full directory commits.. Is this possible ?
I want to version some of the configuration files that I modify on my ubuntu server, but I wish not to do an initial full directory commit, rather i'm looking if it is possible to a add file to VCS just before I am modifying the file.. how could i achieve this ?

A:

I wrote a custom script to deal with keeping the default state of files before editing them &  the current state. [Only these two version of each modified file]. The diff of them(default state & current state) could be used to keep track of all the total changes I made. This would not keep the changes version by version. However this could be used to calculate all total customization I made to files on my system & hence use for later regeneration on another system as well.
Note that this would not provide a backup, but just additional data beside other backup for easily rebuilding new system with my configurations.
Here's the script. (I would execute it prior to making any changes to any configuration file):
#!/bin/bash   

# This is script to remember default & current state of manually edited configuration files.. from anywhere on system..     
# the diffs between current & default may be used to regenerate configurations on another machine.
# Only when used for first time on  a file, it is stored in default state directory otherwise stored in current state directory..

# $1 - 1st passed parameter... this should be subject file  

DEFAULT_STATE_DIR="/root/state-default/" 
CURRENT_STATE_DIR="/root/state-current/" 

FILE=$1

# create the DEFAULT_STATE_DIR & CURRENT_STATE_DIR directories if they dont yet exist.. 
if [ ! -d "$DEFAULT_STATE_DIR" ]; then  
  mkdir $DEFAULT_STATE_DIR
fi
if [ ! -d "$CURRENT_STATE_DIR" ]; then  
  mkdir $CURRENT_STATE_DIR
fi

# fail incase user did not provided full file path(starting from /) in parameter
if  [[ $FILE==/* ]]; then   
    echo "Proceeding.."
else
    echo "Specify full File path starting with /"
    echo "Will stop now."
    exit 0
fi

# convert all '/' in the file path to '-', so the name used contains hint about path as well
FILENAME_TO_USE=$(echo "$FILE" | sed 's;/;-;g')     

if [ -f $DEFAULT_STATE_DIR/$FILENAME_TO_USE ]; # if default state is already stored..then store this as current state..
then
   echo "Initial state for File $FILE already stored. Storing as current modified state.."
   cp $FILE $CURRENT_STATE_DIR/$FILENAME_TO_USE
   echo "Modified."
else
   echo "Initial state for File $FILE didn't existed. Storing the current state as initial state of this file.."
   cp $FILE $DEFAULT_STATE_DIR/$FILENAME_TO_USE
   echo "Added."
fi

