git基础入门

git基础入门

创建初始版本库(目录转换成git版本库)

cd /git
git --version
创建初始版本库(目录转换成git版本库)
git init
vim index.html

添加到版本库,git只是暂存/staged文件

git add index.html
更新版本库 
git commit index.html -m 'add index.html'
文件被add一次后再次修改可以直接commit,无需再次add

查看提交

git log
git show commitID
查看简洁单行摘要,前10个版本
git show-branch --more=10

查看提交差异

git diff ID ID
删除
git rm index.html
git commit -m 'delete index.html'
移动
git mv index.html test.html
git commit -m 'mv index.html test.html'

配置文件

(1).git/config
    版本库特定的配置,针对一个git版本即一个目录。优先级最高
    git config [--file] user.name 'hannah.jiang'
(2)~/.gitconfig
    用户特定的配置设置,可用--global修改
    git config --global user.name 'hannah.jiang'
(3)/etc/gitconfig
    系统范围的配置。用--system选项修改
查看所有配置
git config -l
移除设置
git config --unset --global user.name

配置别名

git log --graph --abbrev-commit --pretty=oneline
git config --global alias.show-graph \
'log --graph --abbrev-commit --pretty=oneline'
git show-graph

查看配置文件

$ cat .git/config
[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[user]
    email = 123@163.com
    name = hannah
[alias]
    show-graph = log --graph --abbrev-commit --pretty=oneline

github的ssh配置

检查本机是否有ssh key设置
$ cd ~/.ssh 
$ ssh-keygen -t rsa

1、 登录GitHub系统;点击右上角账号头像的“▼”→Settings→SSH kyes→Add SSH key。
2、进入cd ~/.ssh/目录下,打开id_rsa.pub文件,全选复制公钥内容。
3、将公钥粘贴到GitHub中Add an SSH key的key输入框,保存

测试ssh keys是否设置成功。
$ ssh -T git@github.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值