Jun
05

安装 git

Linux:

sudo apt-get install git-svn

Windows:

http://code.google.com/p/msysgit/



创建Git Repository



1.在本地创建

mkdir new_repository

cd new_repository

git init-db

2.从已存在的Repository获取


git clone /path/to/exist/repository

3.在远程服务器上创建bare repository

$ ssh myserver.com
Welcome to myserver.com!
$ mkdir /var/git/myapp.git && cd /var/git/myapp.git
$ git –bare init
Initialized empty Git repository in /var/git/myapp.git
$ exit
Bye!

4.在本地添加远程repository并push

$ cd ~/Sites/myapp
$ git remote add origin ssh://myserver.com/var/git/myapp.git
$ git push origin master

5.使用ssh从远程服务器上获取文件

git clone ssh://user@myserver.com/var/git/myapp.git

添加文件



git add /path/to/filename # 添加单个文件



git add filename [filename] # 添加多个文件



git add /path/to/directory # 添加文件夹



git add ./ # 添加当前文件夹



提交文件



1.提交本地更新


git commit -m “commit message is here”



OR



git commit -a -m “commit message is here”



2.提交更新至远端

git push /path/to/repository



更新文件



1.更新本地工作目录文件


git checkout -f





2.更新远端文件

git pull /path/to/repository



创建分支



创建自己的工作分支,以避免对Master Branch 的影响

      git branch raecoo   # 成功创建了名为raecoo的分支

git checkout raecoo # 将当前工作切换至raecoo分支

删除分支

git-branch -D branch-name

合并分支

git checkout master # 切换当前分支到master



git merge “merge message is here” HEAD raecoo # 将raecoo分支与master分支合并



OR



git checkout master #效果与上相同



git pull . raecoo

参考

http://www.robinlu.com/blog/archives/191

http://www.robinlu.com/blog/archives/194

http://toolmantim.com/article/2007/12/5/setting_up_a_new_remote_git_repository

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg

Tags:

No Responses

Leave a Response

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>