git初始配置
配置git账户用户名和邮箱:
git config --global user.email "ceshi@email.com"
git config --global user.name "ceshi"
git config --global --list
配置ssh-key:
ssh-keygen -t rsa -C "ceshi@email.com"
生成key的时候,一路回车,不要输入密码
生成的key在C:\Users\用户名\.ssh\id_rsa.pub
将ssh文件夹中的公钥(id_rsa.pub)添加到github 个人信息设置中 New SSH key
测试配置是否成功:
ssh -T git@github.com
git 配置http代理
设置代理 【http://127.0.0.1:1080是代理地址】
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
常用操作
git 初始化库
git init
git 下载代码
git clone "https://github.com/Arbonkeep/Computer-Operating-System.git"
git 更新代码
git pull
git 回滚
git reset --hard commit_id
git 提交代码
git add .
git commit -m "提交信息"
git push
git 查看提交记录
git log
git 查看分支
git branch -a
git 切换分支
查看本地分支
git branch -a
适用于第一次创建并切换分支
git checkout -b newBranch origin/newBranch
如果已经有本地分支
git checkout newBranch
git 创建分支
git checkout -b 分支名
git 查看修改状态
git status