Tuesday, 13 June 2017

Using Git as a Local Repository for Your Existing Projects

Git is a version control software that helps you to tracking the different versions of your projects.

Git Installation For Windows

Regarding using git in Windows, I found the following post to be useful.

For my Win7 PC, I chosen to use Cmder. 

Creating a new Git repository from an existing project

Say you’ve got an existing project that you want to start tracking with git. The first step is to open a Bash console for the directory containing the project. 

In my case, since I am using Cmder, I can do it through its integration with Windows File Explorer.

Then in the console:

  • Type git init
    • This create a hidden folder for git administration (called ".git").
  • Add ignore files into the global ignore file (called ".git\info\exclude"). These are files that you don't want to add into the repository, e.g. "*.obj".
  • Type git add . 
    • Note that you have to type a period at the end. The use of the period means: add all relevant files from the current folder into git's staging area.
  • Type git commit -m "Initial version"
    • This commits all the files in the staging area as a single version. The -m flag allows you to give a meaningful message to this commit.
Note: if you get error about unable to detect email or name, just type following commands:

 git config --global user.email "yourEmail"
 git config --global user.name "yourName"

Git GUI Client

To easily manage the versions inside the repository, I have used SmartGit as a GUI client. It is also integrated with Windows File Explorer.

You can use SmartGit to view the repository created in the earlier section. It is really easy to use. You can use it to commit new versions into the repository. Remember that you can add messages to describe each new version.

Git Hub

For more information about connecting to GitHub to download projects, you can refer to http://kbroman.org/github_tutorial/pages/init.html

Other References

https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository