git使用
参考:
http://blog.csdn.net/tangbin330/article/details/9128765
http://git-scm.com/documentation
文中会使用svn的相关概念解释
global 设置
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL"
git config --global push.default simple
//why simple:only push current branch.
显示配置
git config --list
clone(svn checkout)
git clone https://github.com/liushixaing/xxx.git
初始化
git init
添加需要提交的文件(类似 svn changelist)
git add .
删除文件(svn delete)
git rm FILENAME//会自动删除文件
查看提交前的不同(svn diff)
git diff
提交(svn commit)
git commit -m "some message"
git commit -a -m "some message" 合并了git add
.或者auto
没提交之前的文件怎样还原(svn revert)
git checkout filename OR git checkout .
新建分支 (svn copy)
git branch [new branch]
git checkout -b newbranch
git checkout -b newbranch
bbccdd30sdfl从历史版本中迁移处新分支
更改所在分支
git checkout otherBranch
删除分支(svn delete 目录)
git branch -d branch
合并分支(svn merge)
git merge
显示日志(svn log)
git log
显示git状态(svn status)
git status
更改进度
git reset LOG --hard
同步(svn commit 就会同步)
git remote add origin https://github.com/liushixiang/xxx.git
git pull
push
git push origin master
把当前分支push到origin的master分支;origin是远程的仓库别名;origin master 可以省略.
push之前如果本地版本跟远程版本不一样需要重新git pull(svn update)否则不能git push
本地新branch在第一次push之前需要先指定push分支名称.否则下次还有输入全部命令:git push test maintainer
git push --set-upstream test maintainer
显示已经有的远端仓库
git remote
删除
git remote remove origin
改名字
git remote rename origin neworigin
还原未提交的更改
git clean -f 删除刚刚添加的文件
//git clean -n 没用
git checkout filename 只是回复这个文件的原始状态
git checkout . 找回全部删除文件
合并分支
git checkout master
git merge otherbranch

浙公网安备 33010602011771号