git 常用命令

配置用户信息

  git config --global user.name 'xxxx'

  git config --global user.email 'sfasd@ksyun.com'

git 设置代理 比如跳过gfw (Git 设置和取消代理(SOCKS5代理))

设置代理

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy

针对 github.com 的单独配置:

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy
details/84748009

直接使用 socks5 的速度很快,近百兆的项目能在短时间内下载完。

 

下载(拉取)代码库

  git clone git@github.com:账号名/项目名.git

与远程交互

从远程库获取到本地

  git pull

将本地提交远程库

  git push origin master

本地版本管理(工作区<---->暂存区<---->仓库区)

提交

  【工作区】--->git add 文件名--->【暂存区】--->git commit -m "备注" 文件名--->【仓库区】

查看

  【工作区】<--git status-->【暂存区】

记录  (仓库区)

  git log 查看详细提交记录

  git log --pretty=oneline 每行一条记录

$ git log --pretty=oneline
bcf24e3eba0400abda3be8d7bad0247a275fadf3 (HEAD -> master, origin/master, origin/HEAD) 更正闹铃客户列表显示:取消居中
081bc55d33c7d570f6f9d79a26d14c61b9675863 数据库 直连用户数据批量修改
68c9ced8b18e59734f802730838bd5dc359856d6 模块化部署交接系统---启动入口

  git reflog

回退

  【仓库区】--->git reset 版本号码【暂存区】--->git checkout--->【工作区】

  示例回退

git reset bcf24e3eba0400abda3be8d7bad0247a275fadf3
git reset HEAD  回退上一个已提交的版本
git reset HEAD^ 回退上第二个版本
git reset HEAD ^^ 回退上三个版本
git reset HEAD~100 回退上100个版本

  确认版本内容覆盖本地文件

git checkout

 

posted on 2020-06-19 19:45  zhangmingda  阅读(136)  评论(0编辑  收藏  举报

导航