on Git: tips for SVN users and Git in Dropbox cloud
I gave in to the hype of Distributed VCS and decided to learn Git about 6 months ago (No, it’s not a hype, even for single person projects). I started managing my latest projects with Git. Learning Git was not a cake walk, but I put my faith in Git’s promise of power and climbed the beginning slope of the learning curve. If you are switching to git after using Subversion for years, then this slope can be steeper. But now I am comfortable with my Git setup and starting to see the glimpses of power that git has to offer.
Here are few tips for subversion users shifting to Git, which could have saved me some agony when I was new.
1. How can I do svn revert in Git?
Believe it or not, but you do that with git checkout . When I first learned that, I was shocked. (And the best part is, the manpage of git-checkout talks about this functionality only in 3rd paragraph and in not so clear words). Over time you will find out that “checkout” is highly overloaded sub-command in git. Besides reverting your changes, it is used to switch to new branch, or create a new branch altogether. Its semantics are nothing like svn checkout. (The closest git analogue of svn co would be git clone, but not exactly)
2. What’s all about branching being easy in Git?
Once your projects starts to grow beyond certain size, you appreciate the ease of branch management that Git provides. But it takes little effort to understand it. In Subversion, the central repository lies on a web server or a backed up disk partition. You as a user, “checkout” a local copy of it. In Git as well, there can be a center repository (but it’s not necessary), however you do not checkout code from it. You as a user “clone” the entire repository. Because the entire repository is available locally, creating, deleting and switching between branches is very fast. Others don’t see your branches unless you create a corresponding remote branch on central repository (check git push and –track option of git checkout to find out more about it)
3. Here are two useful git subcommands that I wish were more publicized, rather than documented like corner cases.
stash
When you start using multiple branches, more often than not you are faced with a situation where you have some uncommitted code in branch B, but to fix a customer reported crash you want to immediately switch to branch A. When I first faced this situation, all I could find was do a commit and switch the branch. After some later point I accidentally came across ‘git stash’ and found how handy it was.
cherry-pick
You are working on some new feature in branch B and you find a critical bug while doing it. You find the fix for it and you want to release it immediately without waiting for this feature to complete. Your releases are built from branch A (from which you create B). Commit your fix in branch B (don’t include any feature code in that commit), then git the SHA id of that commit to cherry-pick.
4. git mergetool
Git has the most intuitive conflict resolution mechanism in the form of git-mergetool. Actually, I am not sure if it’s git or (g)vimdiff that deserves the credit (or both). After doing merges across branches, if you end up with conflicts, then use git mergetool –tool=vimdiff (git may automatically prompt you for this). I have done some merges with Perforce in the past (they call it crossport, integrate, etc.), and suffice it to say it was bad enough for me to avoid that task altogether. But the three windowed diff view makes this task as intuitive as possible.
5. Best Git GUI I’ve found so far: Git-cola
6. Book recommendation: Progit (It’s Free. It explains different use cases with examples and that helps a lot)
Now on to the second part of the post. Something that I discovered recently. First understand that, you don’t need any central repository to git-fy your project. You have a directory of source files and you want to start tracking it with git, just do git init and you are good to go. git-add, git-commit, git branching all can be done after this point.
However, in little bigger use cases you need a central repository. In my case, I work on same project from two different machines located at two different locations. I could create my git repository on USB key and carry it around with me. But it’s not reliable - media corruption, physical loss, theft - you get the point. So it’s advisable to have your central repo in cloud.
I rented such service from repositoryhosting.com for $6 per month. They provide many other project management tools in the package too, but I primarily used it for git. Recently I started using Dropbox. Although Dropbox storage resides in cloud, they have done perfect job of exporting it as native file system. More importantly it works on all three platforms. So for all practical purposes (that I have covered in last two weeks at least), it’s a native file system, but magically synced across different machines. So I just created the git clone of my git repositories in one of the folders inside Dropbox. I can now push and pull to/from this repository on different machines. See this post for detailed instructions.
Dropbox comes with 2GB of free storage and by doing some referrals you can stretch it up to 2.5GB. It’s plenty for versioning source code files, don’t you think? Be careful not to version big files though (release binaries for instance), you won’t be able to free up space by removing them once they are in the repository.
I hope you found the git tips useful. Hoping to explore more of git.
Archive
2019
Dimensions of Idea communication
2018
Lessons for Game designers from "Structure of Scientific Revolutions"
Playing games, Doing Mathematics
Why gamers like pixelated games
2017
Collecting Vs Hoarding Netflix
Game Design tip for Programmers - Less Automation
Review Ghost In The Shell - The blinds scene
Why Electron is the best development platform?
2016
2015
Before fixing performance issues
2014
2013
Software Engineering Code of Ethics and Professional Practice
2012
Coffeescript: To switch or not to switch
The single most reason that keeps me using Vim
When your git branch diverges from your remote
Something like Olivia - John Mayer
Online courses - New technology, Old rules
Why Patriotism doesn't make sense
Why sea steading is important to pursue?
Rolling back latest git commit
iTunes Download stopped (err =9006)
Good essay on user centric software design
Why we need to explore Seasteading?
2011
How to write interactive CLI utility in node.js
The Gods Themselves by Isaac Asimov
How to print stack trace anywhere in Javascript
It's not fair to compare Android with Internet Explorer
How to debug WebWorker threads?
Why can't I criticize Government if I don't vote? I sure can.
Why the hi-tech minds are writing Social apps?
Ever growing todo list is a good sign for creative projects
Lesser women in tech... So what?
HTML5 offline cache - use swapCache carefully
How Wikipedia and Flattr can together change the World
2010
Functional programming in Javascipt using Underscore.js
Youtube ETA - Chrome extension
Why secure airports when it's planes that fly?
Mac book red light audio jack problem on Linux
How to save HTML5 canvas image to Google App Engine
Why don't they publish eBooks for free but with embedded ads?
Reality distortion field around
ReaderScope 2.0.6 - Find Comments
Why "Open" is not the first concern of user?
Mutt, Gmail, gdata, notify-send: A Perfect Email solution
Are you the Matt Damon of your game?
ReaderScope 1.8.{2,3} - new authentication and global share
Portable apps for iPhone, Android, Pre, n900 - Can Processing.js help?
ReaderScope 1.8.1 - rethinking features
Android fragmentation : How big a deal is it?
ReaderScope v1.7 - Widget, new Icons and .... Ads
on Git: tips for SVN users and Git in Dropbox cloud
How to do an online IDE for Android app development
Make Android speak your Twits with "TwitSpeak"
2009
ReaderScope 1.5 - quicker, better, prettier
Preview android.R.drawable.* images
Is definition of "Evil" changing?
ReaderScope 1.4 (with a Theme Pack)
The AND-OR problem of laptop and mobile phone
ReaderScope v1.3.3 - offline podcasts
ReaderScope v1.3.2 - Social Channels
ReaderScope v1.3 - Beyond Google Reader
Frets on Fire for Maemo - Update
ReaderScope 1.2.7 - Podcasts, Expanded View
Sprint HTC Hero problems with ReaderScope
ReaderScope 1.2.1 - Auto Login
ReaderScope 1.1.3 - SDCard storage
ReaderScope 1.1.1 quick-n-easy features
ReaderScope 1.1 - Social Beacons
ReaderScope 1.0.2 - making deep cache simple
ReaderScope beta4 - offline fun
ReaderScope beta3 - Tweet the news
Intercepting Up/Down keys from bash script
Makeshift XML beautifier in python
HTC Magic (Indian version) - expectations and facts
Android development with Vim + Eclim
FoF - PyOpenGL = miniFoF (possibly for n810)
Twitter client with inkface-pygame v0.2.2
Frets on Fire on Maemo 5 (Fremantle)
Static IP configuration on Fedora 10
Smooth scrolling with Inkface+pygame
Inkface v0.2 update and automated GUI testing
Testing Android (Koolu Beta 3) on Openmoko Freerunner
Clutter animation paths with Inkscape+Inkface (v0.1.3)
Debian repository on Google App Engine
Inkface v0.1.2, Twitter-inkface client
2008
Debugging python reference counts
(k)ubuntu 8.10 - not ready for my home yet
Migrating to Google App Engine
Android opened - first looks inside
Inkface - SVG based GUI design
Today's slashdot and open source
OpenMoko, Android and a great hacking post
2007
XML RPC server inside apache mod_python
Nice review article on virtualization technologies
Once again... a quote from 'Troy'
Sea surfing under the Golden Gate
2006
How do I backup to Amazon S3 storage service
Gas prices... seems like big scam
If Harry Potter were a computer hacker ...
2005
repeat (ps | grep) = filtered top
Halo fixed on ATI Mobility Radeon 9000
Warning: const is a keyword in ANSI C
2004