版本控制学习笔记

apt-get install git安装
看版本
git --version
(远程仓库)remote repository   (本地仓库)local repository     (git add 就在这)staging area   working directory
git init 本地创建仓库(repository); .git(隐藏文件)


(远程建仓库仓库)
git clone git://github.com/hello-world.git
git remote -v 查看远程仓库的地址
git push(提交)
git format-patch origin	/master(打补丁)

全局(在.git/config可以看见)(总仓库)
git config --global -user.name "名字"
git config --global -user.email "邮箱"
局部(在.git/config可以看见)(每个仓库)
git config  -user.name "名字"
git config  -user.email "邮箱"
git config --list(查看上面的)

分支
git branch查看分支

git branch xxx 建立分支

git checkout xxx 切换分支
合并分支
git checkout master 
git merge "mmm" HEAD xxx

版本
git tag  -a v1 (版本1)
git tag  -a v2 -m "va2"(版本2)

命令:git add  main.c(文件名)
working directory =》staging area
命令:git commit -m "1 commit"(提交)
staging area=>repository 
一步到位命令
git commit -a=上面两个命令

git status 查看状态(哪些没提交,哪些被删了)

git diff :比较 workspace 和staging 
git diif --cached :比较staged和local repository 

git checkout -f HEAD(在仓库拿回文件)
git checkout -- main.c

git hash-object main.c(计算文件hash值可以省空间)
(添加当前目录所有文件)git add . (在.git/objects目录可以看见文件hash值的头两个字节)

find .git/objects/ -type f(列出所有文件)
git show (文件头2.5字节)可以看见文件内容

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值