git 常用命令和存储组织结构


存储组织结构

在这里插入图片描述

  • 使用 git add xxx 会将文件添加到暂存区,暂存区其实是一个抽象的概念,实际操作是往 .git 目录添加了blob 文件;
  • git commit xxx 会生成 commit 文件而 commit 文件 借助一层或多层tree 文件 指向 git add 添加的 blob 文件;
  • git relog 能保存所有提交的记录,即使分支已经删除;
  • 分支只是一个指针,其实就是文件名为分支名,文件内容里保存了指向的 commit-id;

查看存储内容命令

cat .git/config 	# 当前代码仓库本地的配置文件
cat ~/.gitconfig 	# 全局配置文件
cat .git/description # 当前代码仓库的描述信息,一般都不会写
git cat-file -t commit-id    # 查看 objects 的文件类型
git cat-file -p commit-id    # 查看 objects 的文件内容
git cat-file -s commit-id    # 查看 objects 的文件大小
git ls-files     	# 列出当前暂存区的文件列表信息
git ls-files -s  	# 列出当前暂存区文件的详细信息

HEAD 相关说明

  • head 指向当前活动的分支;
  • head 总是指向最近一次的提交;

常用命令

  • git --help

  • git --version

  • clear

  • git status

  • git init

  • git config user.name “XXX”

  • git config user.email “XXX”

  • git config --global merge.tool bc

  • git config --global mergetool.bc.path “D:\XXX\xxx”

  • git config alias.logg “log --oneline --decorate --graph” // 别名

  • git add -A

  • git add .

  • git commit

  • git commit -m “update a file”

  • git commit cmd.txt -am “edit cmd.txt” //改动的文件

//GitHub

  • git remote -v # 查看远程服务器地址和仓库名称
  • git remote show origin # 查看远程服务器仓库状态
  • git remote add origin git@ github:robbin/robbin_site.git # 添加远程仓库地址
  • git remote set-url origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址(用于修改远程仓库地址)
  • git remote rm # 删除远程仓库
  • ssh -T git@github.com
  • ssh -Tv git@github.com
  • ssh-keygen -t rsa -C “yourmail@gmail.com”

  • git log --oneline
  • git log -1
  • git log -2 -p
  • gitk
  • git log --oneline -graph

  • git clone 443 错误 :

fatal: unable to access ‘https://XXXX’: Failed to connect to github.com port 443: Connection refused

  • 需要设置代理

设置代理

  • git config --global https.proxy http://127.0.0.1:8888

  • git config --global https.proxy “http://127.0.0.1:8888”

  • git config --global https.proxy https://127.0.0.1:8888

  • git config --global http.proxy ‘socks5://127.0.0.1:8888’

  • git config --global https.proxy ‘socks5://127.0.0.1:8888’

取消代理设置

  • git config --global --unset http.proxy
  • git config --global --unset https.proxy

已有仓库

cd git_repo
git remote add origin https://gitee.com/dataw/vue-demo.git
git push -u origin master
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值