Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Saturday, 3 February 2018

Why TortoiseGit is so amazing

I had been using Git for a very long time and this is the best version control system that I ever used. In the past, I used centralized version control system: CVS, SVN, Visual SourceSafe, and TFS.  I heavily use TortoiseGit and I use git bash only if the feature isn't there on TortoiseGit . I also develop in Linux and I used Samba share drive or VirtualBox network share to be able to access my source code outside of Linux, so that I could use TortoiseGit on my codes.

Here is how Git changed my development style and quality of my code:
  • Personal code review before committing - In TortoiseGit, it is very easy to see the diff of your current code change and the last commit via the included UI diff tool (I also use an external tool called WinMerge which is more faster). This diff will direct me to the exact place where I did my modification and this gives me a chance to have a second look if I accidentally forget or misplace something like reverting some debug compilation symbols that shouldn't be on production release.

    I noticed that git bash users (at least from the people that I know of) never do personal code reviews before committing and I think it is because it is not very straightforward to do so like in Tortoisegit. There was a project in my previous company where the developer unintentionally added a code which made the software release very unstable. They found out that some test snippets were included on the commit. A quick review of the software before commit will save tons of headaches.
  • Stash - I love this feature. This helps me move through different git branches without committing my modified file and instead stash saving it and popping it out if I need to continue working on the modified files.
  • Reviewing codes from other committers - It is very easy to review code from other committers via git log compare revision on TortoiseGit. This helps me review other developers work.
  • Revert on TortoiseGit - whenever I do code review, and if I see that some of the codes needs to go back to its original state, I can just simple do a revert on the commit windows dialog box of TortoiseGit. 
  • Very easy to merge codes
  • Bisect - I used this only once. But bisect feature is very impressive.
  • Distributed- being distributed is a very very very very very good thing. I commit often and sometimes, I don't have an internet connection. With this, I can commit anytime and once I have an internet connection, then that's the time I can push to the git server.

These are the things that I really like  in TortoiseGit which I had been using for many years. It is very simple and yet powerful.

Saturday, 4 February 2017

Why Git?

On this post, I would like to highlight the advantages of using Git based on my personal experience. I am currently using TortoiseGit and it helped me increased my productivity. I had used different Version Control Systems (CVS, SVN, TFS, VSS) and I think Git is far more superior than them.

----------------------------------------------------------------------------

Scenario: When I started my career, the way I version control my project is by duplicating/copying the current folder and appending some info onto it. Sometimes, I will zip it. And like for example my project folder name is: MyProject , then I will copy it and rename it to MyProject - Dec 25, 2003 Version 00.08.00 Beta – Added unit test.

I even took it one step further, I created a Python script to automate the archiving and ignore all the files the doesn't need to be stored (like all files and sub-directories on bin\ and obj\).

Problem: Most of the times, you need to see the difference of the original and modified file. It will be very difficult to diff and compare the project files using the scenario above. How git resolves it? With git log, it is easy to compare the files and you can do a personal code review before doing a commit and this is a very big plus. I can also easily see if I accidentally deleted or unintentionally modified some of the codes. Plus, every log has some comments.
Problem: Using the primitive way of copying project folders manually, you will also be copying all the unnecessary things like executables and object files which you can always generate and this may also increase the size of your archieves. How git resolves it? Just create one text file (.gitignore) and it will ignore all the files to be committed.
Problem: People thinks that archiving the project into zip files will yield smaller backups. How git resolves it? That thinking is wrong. I had an old project where I archived it using zip files. I manually ported them to TortoiseGit (and I admit, it was tedious to re-commit that project and I should have used Git in the first place). After finishing, I went to Git Bash and run git gc. Bam! My total git repository size was far way smaller than all the zip files combined!

Conclusion on this Scenario:
I personally feel that the copying of files and/or manually archiving it into zip files is not a good way of doing things. Although that Python script worked perfectly, I think that it was a waste of time.

----------------------------------------------------------------------------

Scenario: Before, the way I reuse source code modules is by copy pasting the source codes into project folder.

Problem: Maintenance problems. Updating all the copies will be very difficult. If you modify that common code and you would like all the projects to use it, then you need to copy paste the updated files. Plus, you don't have any trace-abilities. How git resolves it? Git submodules! This is one of the best features of Git that I love. I have 3 projects and they share one library which is still evolving and being updated constantly. This one shared library is a submodule of the 3 projects and they refer to a single Git repo. Whenever there are new updates, I just do a Git submodule update.

----------------------------------------------------------------------------

I really love Git and I hope I learned it a few years back. I can easily do trial and error on my codes, and if don't like the outcome, I could easily revert it using Git. I can also put my current progress on-hold without committing (using Stash) and go to different branches. I almost use it in everything (e.g. Password manager, resume/CV [I use the diff in MS Word], version control during picture editing). The logging mechanism of any VCS is important and I hope people will start using Git (or any VCS) instead of copying and/or zipping project folders.