【原】Git常用命令集合

 

下载代码到本地


 

1. 先创建放代码的文件夹,初始化:git init

2. 添加远程仓库:git remote add origin http://*******************************.git

3. 下载远程代码:git clone http://*******************************.git


 设置与取消代理


1. 查询当前用户配置:git config --global --list

2. 查询系统配置:  git config --system --list

3. 查询当前仓库配置:git config --local --list

# 设置socks 
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 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 

 

 常用实用命令


 

  • 回滚到某个commit:
    1. git log (查看提交记录);
    2. git reset --hard commint_id;(回滚到指定的版本)
    3. git push origin HEAD --force ;(强推到远程服务器)
  • 查看远程分支:
    • git pull  
    • git branch -a
  • 切换到远程分支:
    • git checkout -t /origin/branch_name
  • 合并分支:
    • 查看某次提交记录:
    • git log -p commitId
  • 查看两个分支里某些路径下的区别:
    • git diff origin/master..origin/dev      

每次git操作都需要输入密码


 

使用Git操作,每次都提示输入命令。 Enter passphrase for key 'xxxx'

输入一下命令:ssh-add -K 'xxx'

posted @ 2019-05-05 10:19  Cooqer  阅读(144)  评论(0编辑  收藏  举报