https 和 SSH 的区别:
$ cd ~/.ssh && ls
进入该文件夹下检查有没有 id_rsa.pub 或 id_dsa.pub 文件,如果存在 则已经创建,没有需要创建
//配置git用户名和邮箱:
$ git config user.name "用户名"
$ git config user.email "邮箱"
$ ssh-keygen -t rsa -C "邮箱"
//多个密钥的情况下,可生成ssh key同时指定保存的文件名
$ ssh-keygen -t rsa -f ~/.ssh/ellacf -C "邮箱"
代码参数含义:
执行后,会填写保存两种密钥的文件夹,和passphrase,全部可以按enter。然后执行ls来查看生成后的文件。
新增 config 文件
touch ~/.ssh/config
在config里面添加
Host *.github.com
IdentityFile ~/.ssh/id_rsa.github
User '用户名'
查看并 copy
1、查看 copy
cat ~/.ssh/id_rsa.pub
或者直接copy
pbcopy < ~/.ssh/id_rsa.pub
2、登录 github ,个人中心 ,ssh key ,添加 Add SSH key
$ssh -T git@github.com
修改本地 .git config 文件
就是把 https 的链接方式
有时候 push 不上去,提示 the project you were looking for could not be found,可能是远程仓库地址换了。
批量
git ls-fies -d | xargs git checkout --
配置 git 使其对文件名大小写敏感
git config core.ignorecase false
最简单的就是在当前的项目里更改 username,当前项目的 username 就是 单独的
git config user.name 'sunyongjian'
git config user.email 'sunyongjian@1111.com'
配置秘钥 key
git show 哈希值
git diff // 查看尚未暂存的文件更新了哪些部分
git diff filename // 查看尚未暂存的某个文件更新了哪些
git diff –cached // 查看已经暂存起来的文件和上次提交的版本之间的差异
git diff –cached filename // 查看已经暂存起来的某个文件和上次提交的版本之间的差异
git diff hash1 hash2 // 查看某两个版本之间的差异
git diff hash1:filename hash2:filename // 查看某两个版本的某个文件之间的差异
feature 分支
//首先从develop切除feature分支
$ git checkout -b feature-xxx develop
//开发完切回develop
$ git checkout develop
//然后进行合并,-no-ff 参数,以保持分支的合并历史
$ git merge --no-ff feature/xxx
//没问题就可以删除feature分支了
$ git branch -d feature/xxx
hot fix
从远程 master 切出分支,不要将本地分支 feature 功能带上
git checkout -b hot-fix origin/master

