目录
新建仓库
初次使用Git的设置
1.用户配置
git config --global user.name "用户名"
git config --global user.email 邮箱
2.生成ssh key
ssh-keygen -t rsa -C "邮箱"
这条指令成功后,主目录(~)会生成.ssh的隐藏文件夹,里面包含id_rsa和id_rsa.pub。
3.添加密钥到github
vi ~/.ssh/id_rsa.pub
将id_rsa.pub中ssh密钥上传至github,其中title可以随意取。
4.测试
ssh -T git@github
出现这句话就表示成功。
push本地项目到Github仓库
1.初始化仓库(repository)
git init
在项目目录下执行
2.添加文件
将文件添加至暂存区:
git add .
(git status可以查看暂存区文件)
3.提交项目
git commit -m "first commit"
4.添加仓库
对于新建立的工程,要在github上添加仓库
git remote add origin git@github.com:yourName/yourRepo.git
5.push到仓库
git push -u origin master
(-u参数会把本地的master分支和远程的master分支关联起来)
常用命令说明
配置文件
[alias]
co = checkout
br = branch
ci = commit
st = status
f = format-patch
sm = send-email
[user]
email = xxx
name = xxx
[core]
editor = vim
git 设置和取消代理
设置ss代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
设置http代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
git bisect
git bisect start [终点] [起点]
git bisect good / git bisect bad
git bisect reset