Getting git gui back on OSX Mavericks

I have been using git and its default gui with

git gui

for almost from the beginning of my git usage. While everything was smooth for a long long time, recent update to OSX Mavericks, broke that experience. Well, for a new OS, its good that they have already installed a version of git with the OS itself, so new comers do not have to worry but just use git. But this git is from Apple and does not have the default “git gui”.
Now following the old method, I tried to install git again by downloading it from
git-scm site. While everything went well and the install was smooth, I still does not get “git gui” from the command-line.
The default Apple-git was firing up always instead of the “git-scm” version. The trick here is to add the “git-scm” version to the system path. Now that can be done in many ways for a MAC, I did it, by modifying the file “.bash_profile” (dot bash_profile) the name begins with a DOT and its a system file present at the “~/” location.

The paths in OSX may be surprising at first if you are coming from windows environment, but just remember
/ -is the root folder of the OSX
~/ -is the root folder of the logged-in user

The line to add in the end of the file, is as below

export PATH="/usr/local/git/bin:$PATH"

Thats all, I closed the Terminal window and re-opened it to get my favorite “git gui”.
Happy Coding.

Removing the tracking of files, already tracked by Git

If you work on Git then you must be knowing once we fork(or initialise a repository) a repository, all the files inside that folder get tracked automatically by Git. Well, thats not a problem if we really want all of them to be tracked all the time. But the problem starts when there are some files we need not track. And the worse happens when all of the files are being tracked and now we decide to remove some files from being tracked. The handy command is

$ git rm --cached readme.txt

And for folders

$ git rm --cached docs/

There is an option to set a rule for Git to ignore all the files, one need Git to ignore from tracking. This rule is set in a file named .gitignore. Remember there is a dot (.) before gitignore word name. All those files which need to be ignored must be mentioned in this .gitignore file. The tricky part is .gitignore will not remove files from tracking by Git if those files are already being tracked by Git. In those case the above “git rm –cached” trick will help.
The way I do it regularly is add the .gitignore file in the beginning inside the folder I am going to initialise Git repository. That only works if I know which files I need to ignore in the beginning only.
There is a set of .gitignore templates for different languages at Github, That is a great help in the beginning of configuring the .gitignore for different languages.

My basic day-to-day Git commands

Ever since I have started using Git, it feels more fun to work on command-line. At first it was very daunting to me. But as with any new thing, we have to practice it until we are comfortable. Same happened to me. As I have promised myself to go Git way, I have started using it more and more. It was not easy for a person coming from SVN with tortoiseSVN client on windows to a pure command-line tool. Though tortoise has released visual client for Git, I must say, if you use command-line there is no way you will love any UI for Git. I am still learning it and not at all a mature user, doing all complicated things with it. That said, I am kind of getting comfortable with it now.
I am putting down here, what are the commands I use on a regular basis.

//very frequently used
git add . //adds everything in the directory to commit
git commit -m 'comment for this commit' //commits to local repository
git push origin master //commits to the remote repository
git status //checks the status of the repository
git log //displays all the log for the current repository

//some one time things
git config --global user.name "Saumya Ray" // done once for a computer
git config --global user.email "name@domain.com" //done once for a computer
git init //start using GIT, initialises the current directory for GIT
git clone URL //URL to get the repository from

Those are some which I use very regularly.

GitHub has got some very nice tutorials to get one started with Git. Here is cheat sheet link of it. And here is the link which talks about dealing with Remote in Git.