您的位置:首页 > 其它

git 用法记录,方便以后

2017-09-08 15:38 706 查看
1,$git status查看分支状态2,$ git add .gitignorefatal: pathspec '.gitignore' did not match any files$git add . 添加所有添加到本地仓库3,$ git commit -m "20170908"[master (root-commit) 70642cf] 20170908提交本地并添加相关信息4,$ git checkout -b harrySwitched to a new branch 'harry'切换到其他分支5,$ git pull远程仓库代码拉下来6,$ git push origin master提交到远程服务端7,$ git logcommit 047c868f052fe450da6e38709520c80026b1598cAuthor: 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 c011eb3c20ba6fb38cc94fe5a8dda366a3990c61
revert 使用,需要先找到你想回滚版本唯一的commit标识代码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git