写在前面:
强烈推荐一本学习git的书籍《看日记学git》,请一定要看:如果你使用linux开发,且对命令不是很熟练。
============about git==================
1.git代码提交
git status
git diff
git add .
git commit -m "your comment"
git fetch;git rebase
git push origin HEAD:refs/for/master
参考:
http://blog.csdn.net/crylearner/article/details/7685158
2.git working tree rollback
============================================
- git checkout file1 (回滚单个文件)
- git checkout file1 file2 ... fileN (一次回滚多个文件,中间用空格隔开即可)
- git checkout . (直接回滚当前目录一下的所有working tree内的修改,会递归扫描当前目录下的所有子目录
3.branch操作
创建tempFiger分支:
git branch tempFiger
删除tempFiger分支:
git branch -d tempFiger
切换到master分支:
git checkout master
显示所有分支:
git branch
4.git clone
ex1. git clone ssh://pe----ng@19-----84:29418/tz
ex2. git clone http://p------ng@1------4:29418/tz
详见:《看日记学 git 》之十五
5.query commit history
git show changeId ex: git show 5b888402aadd3cd41b3fe8c84a8658da07893b20
git grep "grep content"
6.local git 组成 及 对应提交环节
current working directory working tree 1
index file index file 2
git local respository commit 3
others:
git log -p
git commit amend
git diff 12
git diff --cached 23
git diff HEAD 13
可以同时有n个local git存在
7.git提交到github练习
git clone https://github.com/codefiger/spring-mvc-mini.git
cd spring-mvc-mini/
(开发...编译...测试...)
git status
git add .
git commit -m "just add a system"
git fetch;git rebase
git push -u origin master
git log
others:
git log -p
git commit amend
man git -****
git branch 查看已经存在的分支
git merge
git reset 撤销修改
git checkout 撤销修改 or switch to another branch
git pull == git fetch;git merge
git pull --rebase == git fetch;git merge
git merge & git rebase 区别:merge会生成一个新得合并节点,而rebase不会