git

Displaying information about your git repository

Want to see information about your git repository?

Based on a discussion here Duane Johnson wrote a very useful bash script. I am using this script from months and would like to share with you. You can download this script here(git-info.txt (236)).

You can also add an alias like below, so that I can be a accessed by a single command “gitinfo”

alias gitinfo="/home/akhil/git-info.txt"

When you run this script from your working copy it displays:

  • Remote URL
  • Remote Branches
  • Local Branches
  • Configuration (.git/config)
  • Most Recent Commit

Isn’t it useful, give it a try ;-)

Export Mercurial(Hg) repository to git repository

I have been using a git from quite a some time. But there was a project for which we were using Mercurial(Hg).

We decided to move it’s repository to github, after spending some time on google I found many articles but unfortunately none of them worked for me.

But, Finally I managed to move it from Hg to Git.

Following are the steps I followed:

  1. git clone git://repo.or.cz/fast-export.git
  2. mkdir new_git_repo
  3. cd new_git_repo
  4. git init
  5. /path/to/hg-fast-export.sh -r /path/to/hg_repo #hg-fast-export.sh in the clone of step 1
  6. git-repack -a -d -f
  7. git checkout BRANCH_NAME # BRANCH_NAME is the name of Hg branch, in my case it was ‘trunk’

It worked for me very well, hope same to you guys…

Git Error: trailing whitespace, indent SP followed by a TAB, unresolved merge conflict

I have been using Git from last few days, and faced following errors while committing:

1) Trailing whitespace
2) Indent SP followed by a TAB
3) Unresolved merge conflict

The first error “Trailing whitespace” is because of carriage-return/line-feed(windows style line feed/end). To resolve this problem comment following lines(58-60) in .git/hooks/pre-commit file:

  if (/\s$/) {
    bad_line("trailing whitespace", $_);
 }

The second one “Indent SP followed by a TAB” is because of leading spaces/tabs. To resolve this problem comment following lines(61-63) in .git/hooks/pre-commit file:

  if (/^\s*   /) {
    bad_line("indent SP followed by a TAB", $_);
  }

The third one “Unresolved merge conflict” is because of seven or more successive occurrence of = or < or > characters. Major chances of having seven = character in README or doc files. To resolve this problem replace following line(64) in .git/hooks/pre-commit file:

  if (/^(?:[<>=]){7}/) {

by

  if (/^(?:[<>=]){7}$/) {

These tricks worked for me, I hope it could help you.

Git – Fast Version Control System

Git is getting popular in Rails community these days, as there were being many changes in rails to support Git.
Git is a open sourse fast version controller system. It was originally designed by Linus Torvalds to handle large projects. It was inspired by Monotone & BitKeeper. It is a distributed version controlling system. It gives you ability to commit, traverse into history while being offline. Actually every working copy of Git is a full-fledged repository. It has no central server like SVN. One can share his working-copy/repository by using various protocols like ssh, http, ftp etc. One thing I like about Git over SVN is that the size of Git’s repository, which is smaller compared to SVN.

I gave an introductory presentation in VinSol. I am sharing it with you, this is not very explanatory as I focused on speech more. Please share your views.