读书人

Git适用指南

发布时间: 2012-07-16 15:44:59 作者: rapoo

Git实用指南
年初的时候,在给自己的小站找托管代码的服务,从而了解到Git,官网的介绍

检查当前文件状态
$ git status
跟踪新文件
$ git add README
暂存已修改文件
$ git add benchmarks.rb
提交更新
$ git commit
$ git commit -m "Story 182: Fix benchmarks for speed"
移除文件
$ git rm grit.gemspec
移除跟踪但不删除文件
$ git rm --cached readme.txt
移动文件
$ git mv file_from file_to
查看提交历史
$ git log
Plus:
在Git管理的项目下创建一个名为 .gitignore 的文件,列出要忽略的文件模式

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

4.远程操作
查看当前的远程库
$ git remote
从远程仓库抓取数据
$ git fetch[remote-name]
推送数据到远程仓库
$ git push [remote-name] [branch-name]
查看远程仓库信息
$ git remote show [remote-name]
远程仓库的删除和重命名
$ git remote rename pb paul
$ git remote rm paul

5.分支操作

当前分支和某一分支合并
$ git merge origin/master

git commit support an --amend flag
This gives you an opportunity to add files that you forgot to add or correct typos in a commit message, prior to pushing the change out for the world to see.

To Be Continued...

读书人网 >软件开发

热点推荐