Friday, January 10, 2014

Initial git setup for a local project

Git is a great version control system available for free for private use. It is easy and very efficient. There is a short free book that explains the basics. Here is my short take on how to set up a git project locally (assuming that Git is already installed in the system.)

Open up the command shell and navigate to the root folder of the project. Then, issue the following commands (all comments come after the "#" mark):

git init #initialize a git repository here
notepad .git/info/exclude #optional step, here you can exclude files or folders that need no tracking
#notepad will open with the document where you can type in values.
#If nothing needs to be excluded, just close the file.
#to exclude a folder, mark it as so: bin/
#to exclude all files with extension "sap", type in *sap
git add . #to add all files recursively
git status #(optional)see the files that will be committed.
git commit -m "initial version" #commit with message "initial version"
git log #check what's committed

Update from Feb 28, 2014: Here is another way to set up git locally, the difference between the script above is that the excluded files will be tracked by ".gitignore" file rather than "exclude" file. For sample of .gitignore files, check out this GitHub repository: github/gitignore, there are plenty of examples there for all kinds of programming projects. Here is the script:

And the first commit is done. It's that easy. To utilize tags, branching/merging, and other features of git that make it so good, read the book. The next logical step for the local repository is to create a distributed repository online and upload your code there. Bitbucket or GitHub are a places to start looking around.