Saturday, 24 December 2011

Git Command Quick Reminder

NOTE: You can find an updated version of this article in Git Command Quick Reminder


INSTALLING GIT
$ aptitude install git-core # git basic tools.

NOTE: In Debian Unstable
$ aptitude install git


gitk graphic tool.
$ aptitude install gitk # this graphic tool allows us to browse a git repo.



INITIALIZE A REPOSITORY

$ git init # Creates an empty repository in current directory, or reinitializes an existing one.
$ git init directory_name # Creates an empty repo in directory_name directory.

$ git clone remote_url # clone a remote repo. Passing as argument a local directory this command clones a local repo.

$ git clone --depth 1 git://git.sip.router.org/sip-router kamailio # clones sip-router source code, creating a local directory named kamailio. "depth 1" option means it only takes one revision history. That reduces the amount of history to download, but it disallows cloning, fetching, pushing or pulling from this repo. Then, it is only suitable to generate patches.

$ git clone source_repo dest_repo # clones a local repository source_repo in another local repository dest_repo,
if both are directories.
$ git clone file:///path/to/source/repo file:///path/to/dest/repo # another way to specify local directories.
This way we are sure git does not use hard links when cloning source repo.
$ git clone --no-hardlinks source_local_repo dest_local_repo # clone a repository and copy object files instead of using hardlinks for local repo objects.


GIT SVN