ITeye博客

git入门笔记

houniao · 2010-09-28 20:07 · 小记 · 非技术 · Markdown

修改git配置 git config --global user.name "Don Yang" git config --global user.email DonYangOK@gmail.com

创建一个库,进入要git的目录 git init 将全部该目录下的东西全部放入暂存区 git add * git commit -m 'initial project version'

从已有仓库clone到当前目录newname下,newname是git clone自己建的 git clone git://github.com/schacon/grit.git newname

检查提交状态 git status

工作区域与暂存区域之间的区别 git diff

暂存区域与上次提交版本的区别 git diff --staged (--cached)

从仓库中删除文件 如果在暂存区域中存在该文件必须先删除 git rm --cached 文件

然后直接删除 git rm 文件

修改最后一次提交 首先将新修改的内容放入暂存区 然后用 git commit --amend 进行提交

还原为git库内最新版本 git reset HEAD <文件>

git忽略设置 .gitignore

此为注释 – 将被 Git 忽略

.a # 忽略所有 .a 结尾的文件 !lib.a # 但 lib.a 除外 /TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO build/ # 忽略 build/ 目录下的所有文件 doc/.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

from http://memo.totoro.ws/2009/10/how-to-use-git/ how to use git BY ADMIN, ON 10月 13TH, 2009

create repositry

$ cd /var/git $ mkdir project_name.git $ cd project_name.git $ git –bare init Initialized empty Git repository in /var/git/project_name.git/

$ cd project_dir $ git init Initialized empty Git repository in /Users/shin/Documents/project_dir/.git/ $ git add . $ git commit -m “commit message” $ git remote add origin ssh://user_name@example.com/var/git/project_name.git $git push origin master $ git push origin master

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。