How to create Git shortcut aliases?

November 4th, 2009 | by | technology

Nov
04

Open the config file in the .git directory, in the project base directory.

vi .git/config

Create an alias section and append aliases to it, one per line.

[core]
      repositoryformatversion = 0
      filemode = true
      bare = false
      logallrefupdates = true
[alias]
      ci = commit
      st = status
      co = checkout
      b = branch
      l = log
      d = diff
      cmesg = log --pretty=format:"%s"

More information at: http://git.or.cz/gitwiki/Aliases

No Comments »

How to make Git ignore files and directories?

November 4th, 2009 | by | technology

Nov
04

When you run the git status command, it will show all files that are not yet committed or added to staged area. There are so many temporary files and folders which you don’t want to add to the source control repository.

To ignore all those directories and folders, create a .gitignore file in the base project directory and add all the files and directories one per line to be ignored by Git. You can also use wildcard names and can also add .gitignore itself to the .gitignore file.

No Comments »

Revision versioning with Git

October 29th, 2009 | by | technology

Oct
29

Most developers jumping from svn to git, miss the SVN revision numbers, using the svn info command. SVN automatically increment a unique revision number on every commit, independent of the number of times, code compiled or build. This unique revision number was used by developers to version their binaries and uniquely identify the version of their apps.

Sample script to provide revision number in svn:

#!/bin/sh
rev=`svn info | grep Revision | awk '{print $2;}'`

git repository

Git doesn’t uses or produce any unique automatic increment number on commit, instead it produces a hash value, which is useless for versioning purpose.

But the solution is simple, as explained by the Michael Dales on his blog, to tag the start point – either on the first commit to the repository or the commit just after you’ve forked for a release. Now, to get a simple increasing revision number for a particular commit anywhere in the tree you take the object you’re interested in and count the steps back until you hit a version start tag, and you’re done.

More Information: http://michaelandlaura.org.uk/~michael/blog/index.php?id=379

No Comments »