// 配置Git用户名
git config user.name 'yourname'
// 配置git邮箱
git config user.email 'youreamil'
git config --list#列出本地所有的配置文件
// 将本地传送至github
git remote add origin git@github.com:yourname/test.git
git pull --rebase origin master
git push -u origin master
git show#通过指定ID查看具体的变化
// 删除origin配置
git remote rm origin
// 或者
vim .git/config #删除origin配置
// 从现有仓库克隆
git clone git://github.com/yourname/test.git
git clone git://github.com/yourname/grit.git mypro#克隆到自定义文件夹
git add *#跟踪新文件
git diff [filename]# 将工作区的文件和暂存区的文件进行比较
rm *&git rm *#移除文件
git rm -f *#移除文件
git rm --cached *#取消跟踪
git mv file_from file_to#重命名跟踪文件
git log#查看提交记录
git reflog#查看分支引用记录
// 使用下面回退版本的方法,需要多次修改mian.m文件的内容,并且添加并提交
// 回到当前版本,放弃所有没有提交的修改
git reset --hard HEAD
// 回到上一个版本
git reset --hard HEAD^
// 回到之前第3个修订版本
git reset --hard HEAD~3
// 回到指定版本号的版本
git reset --hard e695b67(版本号前七位)
git commit#提交更新
git commit -m 'message'
git commit -a#跳过使用暂存区域,把所有已经跟踪过的文件暂存起来一并提交
git commit --amend#修改最后一次提交
git reset HEAD *#取消已经暂存的文件
git checkout -- file#取消对文件的修改(从暂存区去除file)
git checkout branch|tag|commit -- file_name#从仓库取出file覆盖当前分支
git checkout -- .#从暂存区去除文件覆盖工作区
git branch#列出本地分支
git branch -r#列出远端分支
git branch -a#列出所有分支
git branch -v#查看各个分支最后一个提交对象的信息
git branch --merge#查看已经合并到当前分支的分支
git branch --no-merge#查看为合并到当前分支的分支
git branch test#新建test分支
git checkout test#切换到test分支
git checkout -b test#新建+切换到test分支
git checkout -b test dev#基于dev新建test分支,并切换
git branch -d test#删除test分支
git branch -D test#强制删除test分支
git merge test#切换至master分支 将test分支合并到当前分支
git push#完成分支合并
git rebase master#将master分之上超前的提交,变基到当前分支
git help#查看帮助 git help add#查看add命令的帮助