0
点赞
收藏
分享

微信扫一扫

git版本控制系统笔记精细版------学习git有这篇文章就够了

乌龙茶3297 2022-04-24 阅读 153
git前端

(一)为什么需要使用git版本控制系统。

(二)git的下载

(三)git的安装

  • 在这里插入图片描述
  • 在这里插入图片描述
  • 在这里插入图片描述
  • 在这里插入图片描述

(四)git的初始配置

  • 在这里插入图片描述
  • 在当前目录下面新建.gitignore文件,在里面配置需要忽略的规则。
  • 配置忽略的语法/规则
  • (1)以“/”开头表示目录
  • (2)以“*”通配多个字符
  • (3)以“?”通配单个字符
  • (4)以“[]”包含单个字符的匹配列表
  • (5)以“!”表示不忽略(跟踪)匹配的文件或目录
  • 注意:git对于.gitignore配置文件是按照从上到下进行规则匹配,意味着如果前面的规则匹配的范围更大,则后面的规则将不会生效。
  • 例如:a/*,表示忽略a文件夹下的所有文件。

(五)三个“区”

  • 工作区
  • 在这里插入图片描述
  • 暂存区
  • 版本库(区)
  • 仓库

$ git init
$ git init [project-name]
$ git clone [url]

增加/删除文件

$ git add [file1] [file2] ...
$ git add [dir]
$ git add .
$ git add -p
$ git rm [file1] [file2] ...
$ git rm --cached [file]
$ git mv [file-original] [file-renamed]

代码提交

$ git commit -m [message]
$ git commit -a
$ git commit -v
$ git commit --amend -m [message]
$ git commit --amend [file1] [file2] ...

查看信息

$ git status
$ git log
$ git log --stat
$ git log -S [keyword]
$ git log [tag] HEAD --pretty=format:%s
$ git log [tag] HEAD --grep feature
$ git log --follow [file]
$ git log -p [file]
$ git log -5 --pretty --oneline
$ git shortlog -sn
$ git blame [file]
$ git diff
$ git diff --cached [file]
$ git diff HEAD
$ git diff [first-branch]...[second-branch]
$ git diff --shortstat "@{0 day ago}"
$ git show [commit]
$ git show --name-only [commit]
$ git show [commit]:[filename]
$ git reflog

分支

$ git branch
$ git branch -r
$ git branch -a
$ git branch [branch-name]
$ git checkout -b [branch]
$ git branch [branch] [commit]
$ git branch --track [branch] [remote-branch]
$ git checkout [branch-name]
$ git checkout -
$ git branch --set-upstream [branch] [remote-branch]
$ git merge [branch]
$ git cherry-pick [commit]
$ git branch -d [branch-name]
$ git push origin --delete [branch-name]

标签

$ git tag
$ git tag [tag]
$ git tag [tag] [commit]
$ git tag -d [tag]
$ git push origin :refs/tags/[tagName]
$ git show [tag]
$ git push [remote] [tag]
$ git push [remote] --tags
$ git checkout -b [branch] [tag]

远程同步

$ git fetch [remote]
$ git remote -v
$ git remote show [remote]
$ git remote add [shortname] [url]
$ git pull [remote] [branch]
$ git pull origin master --allow-unrelated-histories
$ git push [remote] [branch]
$ git push [remote] --force
$ git push [remote] --all

撤销

$ git checkout [file]
$ git checkout [commit] [file]
$ git checkout .
$ git reset [file]
$ git reset --hard 
$ git reset [commit]
$ git reset --hard [commit]
$ git reset --keep [commit]
$ git revert [commit]
$ git stash
$ git stash pop

如对您有帮助,小手点赞一波。

举报

相关推荐

0 条评论