two links bring you to git
Two sources proved to me of great help:
1. why you want to use git
a google talk given by Linus Torvalds
Linus’s talk will never let you feel sleepy.
2. how to get started
the official git tutorial
A tutorial is always a good start.
If you want to learn more, go to git official website and read the documents.
As mentioned, git may not support Windows as well as linux. Check the official git mailing list for interesting arguments on this.
==== bonus: how I use it ====
1. shorthand aliases and script
aliases to help you type the commands, put them in ~/.bashrc
##begin git related alias gm="git mv" alias gc='git commit' alias gca='git commit -a' alias gd='git diff' alias gco='git checkout' alias ga='git add' alias gr='git rm' alias gb='git branch' alias gl='git log' #gs is moved to a script in ~/bin/ ##end git related
my own gs(”git status”) script is too complicated to live in a alias, here is it in a script file:
#!/bin/bash
#Yuanle Song
#Time-stamp:
#Note: gs will overwrite the default gs command for Ghostscript
print_help_and_exit()
{
echo "gs - better git status for you"
echo "usage: gs like \"git status\", but give a warning if "
echo " not using a .git repo in current dir."
echo " gs ~/bin like gs, but run gs on the given dir."
echo "Note: overwrite the default gs command for Ghostscript."
exit 0
}
find_git_repos()
{
#find $real_repos for $gsdir
#@return: the repos dir if there is one, otherwise return "".
while ! [ -d $gsdir/.git ] && [ -n "$gsdir" ]
do
gsdir=`echo $gsdir |sed -n "s/\/[^/]*$//p"`
done
real_repos="$gsdir"
}
gs()
{
#better git status command, will display a warning if there is no .git
#in current dir and there is one in upper level dirs
#also accept a dir name as argument, which means show gs for the dir
if [ "$1" == "--help" ]
then
print_help_and_exit
fi
if [ -n "$1" ]
then
gsdir="$1"
warning_str="given dir"
else
gsdir=`pwd`
warning_str="current dir"
fi
if ! [ -d "$gsdir/.git" ]
then
find_git_repos
if [ -z "$real_repos" ]
then
echo "gs: error: no repos in ${warning_str}."
exit 1
else
echo "warning: using repos $real_repos"
fi
fi
cd "$gsdir"
git status
}
#gs is a function because it used to be hosted in ~/.bash_aliases
#I want to keep it a function here
gs $*
2. global git ignore pattern, put it in ~/.gitignore
To know more about how to ignore a file, read “git help ignore” or “man git-ignore”.
#system wide git ignore file #build files build/* *.elc *.pyc *.[oa] TAGS *.class a.out #temp files *~ *# *.swp #miscellaneous .sconsign.dblite #other version controlling system .svn
3. a script to check and report changed repositories for a list of repositories
leave a comment if you want to get it.
4. a script to do git gc for a list of repositories
leave a comment if you want to get it.
script 3 and 4 are on my cron job, seldom run manually.
There are lots of tips for git on the internet, don’t try to learn them all. The commands in the tutorial and on my aliases will possibly be all the commands you need for small projects.
Oh, one more thing, there is no git pull and git push in my aliases, because up to now I don’t use an online git server for my own projects. If you pay for a private git server, you probably want to add those aliases and a cron script to push your local repos to online server as well. Do *not* put your configs and trivial projects on a free git project host server. Although nobody forbids you doing that(actually I see someone did that), I don’t think that is a right thing to do.
That’s it for git.
September 22nd, 2009 at 12:48 pm
edit: all DVCS are alike. knowing one of them will help you learn others very quickly.
Most of what git provides can be found in hg as well. The basic concepts are the same.