1. git与svn差别
svn有客户端和服务器,服务器断开则无法使用。
2. git的安装(linux ubantu)
#sudo apt-get install git
#git --version
3. github
git的社区
4. git学习网站
git reference --> (gitref.org)
5. 全局配置
#git config --global user.name gexy // 配置名称
#git config --global user.email gexy@qq.com
#git config --global color.ui true
全局标示可以知道谁修改了代码,谁提交了代码, color.ui配置后方便观看
#git config --list // 显示所有配置
#cat ~/.gitconfig // 和.bashrc类似, --global就是对该文件的修改
6. 创建repository (知识库)
在工程pro目录下执行
(假设pro目录下有一个文件 a.c)
#git init
#ls -a // 可以看到隐藏文件夹 .git
7. 查看git中的状态
#git status // 查看git中文件的状态
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# a.c // 工作区中的文件
# git add a.c // 加到index
# git status
# new file: a.c
# git commit -m "ok" // 加到最终版本中
# git status
nothing to commit (working directory clean)
# git status -s // 标志位查看状态
MM
# git commit -a // 跳过add
## git commit -am "add and commit"
#git log // 查看commit日志
8. 查看不同
# git diff // 第二个M
# git diff --staged // 第一个M
# git diff (--stat) HEAD
9. 撤销误操作
git reset file // 第一个M
git checkout file // 第二个M
git checkout HEAD file
10. 删除文件
git rm
git mv
11. git忽略不要的文件
echo "*.swp" > .gitignore // 将vim编辑产生的临时文件加入到忽略文件
git add .gitignore // 忽略文件加入