1,$git status
查看分支状态
2,$ git add .gitignore
fatal: pathspec '.gitignore' did not match any files
$git add . 添加所有
添加到本地仓库
3,$ git commit -m "20170908"
[master (root-commit) 70642cf] 20170908
提交本地并添加相关信息
4,$ git checkout -b harry
Switched to a new branch 'harry'
切换到其他分支
5,$ git pull
远程仓库代码拉下来
6,$ git push origin master
提交到远程服务端
7,$ git log
commit 047c868f052fe450da6e38709520c80026b1598c
Author: nith.hou <nith.hou@t**.com.cn>
Date: Tue Sep 5 11:25:41 2017 +0800
查看log信息
8,$ git reset --hard 3c936aee7b3e00f0086434f7e3bdbb43e54995e5
这个命令是恢复到对应版本
穿梭前,用git log
可以查看提交历史,以便确定要回退到哪个版本。
要重返未来,用git reflog
查看命令历史,以便确定要回到未来的哪个版本。
9,查看远程分支
使用如下命令可以查看远程仓库(我这里有一个origin仓库)
$ git remote -
v
origin git@github.com:username
/Animations
.git (fetch)
origin git@github.com:username
/Animations
.git (push)
10,fetch更新本地仓库:
$ git fetch origin master:temp //从远程的origin仓库的master分支下载到本地并新建一个分支temp $ git diff temp//比较master分支和temp分支的不同 $ git merge temp//合并temp分支到master分支 $ git branch -d temp//删除temp
11,$git revert c011eb3c20ba6fb38cc94fe5a8dda366a3990c61revert 使用,需要先找到你想回滚版本唯一的commit标识代码