git 培训课程

一)生成git的key
git keyen

二)
git help
gti help add

三)一些初始化配置
git init
git clone ssh://
git log
主要的四个config
git config --globa core.editor ivm
git config --globa user.name "***"
git config --globa email
git config  --globa color.ui "auto"

四)
git add hello (hello 是文件名)
git commit
git log (git log --oneline)
git status
git push ssh://git@localhost/ testing master

working copy :
cache
repo
remote repo

五)
git diff 两个版本

六)
head
head ~3

七)撤销 (只能撤销本地,不能撤销公司公共版本库(coderreview里面只要还没有提交到公共版本库里面就可以撤销,提交后就不能提交。))
git reset
gitreset --soft<commit>
git reset --mixed<commit>
git reset --hard<commit>  (讲撤销本地的全部修改,慎用。)

--soft:不修改工作树中的文件和仓库索引,保留了add生成的快照,只是退回了commit的过程(相当于退回到commit前,add后);

--mixed:不修改工作树,修改了仓库索引,不保留快照,相当于退回了commit和add两个过程;

--hard:修改工作树,相当于所有东西,包括工作树和仓库,原原本本地退回到指定的

git reset head~
gti reset head~3

八)文件操作
git add
git rm
git mv

九)查看修改
git blame<file>

十)暂存当前修改
git stash 暂存当前修改
git stash apply 取出暂存的修改

git stash apply stash@{num}

十一)创建分支
git branch
git branch<new>
git branch<new><old>
git checkout<commit> -b<new_branch>
提交后才可以创建分支。

十二)删除分支
git branch -d<branch>
git branch -D<branch>

git branch -m<branch> 分支改名

git checkout<branch>
git merge<branch>

十三)分支合并
git checkout<branch>
git merge<branch>

十四)删除分支
git branch -d<branch>
git branch -D<branch> (强制删除,不管你有没把修改提交完成)

git branch -m<old><new>

十五)
显示标签
git tag
创建标签
git tag<new_tag>
取出标签
git checkout <tag_name>
删除标签
git tag -d<tag_name>

备注:不一定不在git branch中,就不存在,可以在tag中(如果之前打过标签tag,额可以用git tag)。

十六)检查出错
git bisect start
git bisect bad
git bisect good 1.0
git bisect <good|bad>
git bisect reset (结束查错)

十七)合并/修改提交  交换两次提交或合并两次提交
git rebase -i<base_commit>

十八)git reflog
git reset --hard 后的解药:
git reflog (查看commit号)
git cherry-pick [commit 号]

猜你喜欢

转载自jackleechina.iteye.com/blog/1897621