美文网首页
GIT的常用命令

GIT的常用命令

作者: 素明诚 | 来源:发表于2020-06-29 15:54 被阅读0次

1.创建版本库

$ git clone <url>#克隆远程版本库
$ git init#初始化本地版本库

2.提交和修改

$ git status#查看当前的状态
$ git diff#查看变更内容
你也可以在vscode中安装Git History Diff这个插件

GIT DIFF

$ git add .# 跟踪所有改动过的文件
$ git rm <file>#删除文件
$ fit rm --cached <file>#停止跟踪文件但不删除
$ git commit -m "备注"#提交你所有更新过的文件
$ git commit -amend#修改最后一次提交

3.查看提交历史

$ git log#查看提交的历史
$ git log -p <file> #查看指定文件的历史
$ git blame <file>#以列表的形式查看提交历史

4.撤销

$ git reset --hard HEAD#撤销工作目录中所有未提交文件的修改内容
$ git checkout HEAD <file>#撤销指定的未提交文件修改内容
$ gir revert <commit>#撤销指定的提交

5.分支与标签

$ git branch#显示所有本地分支
$ git checkout <branch/tag>#切换到指定分支
$ git tag <tagname>#基于最新提交创建新标签
$ git tag -d#删除标签

6.合并与衍合

$ git merge <branch>#显示所有本地分支
$ git rebase <branch>#衍合指定分支到当前分支

衍合的含义

7.远程操作

$ git remote -v#查看远程版本库信息
$ git remote show <remote>#查看指定的远程版本库信息
$ git pull <remote> <branch>#下载代码及快速合并
$ git push <remote> <branch>#上传代码及快速合并
$ git push --tags#上传所有标签

相关文章

网友评论

      本文标题:GIT的常用命令

      本文链接:https://www.haomeiwen.com/subject/xtgofktx.html