GIT常用操作

1、强行用本地版本覆盖远程库
$ git push -u origin master -f

2、bash 中出现乱码问题
$ git config --global core.quotepath false # 显示 status 编码
$ git config --global gui.encoding utf-8 # 图形界面编码
$ git config --global i18n.commit.encoding utf-8 # 提交信息编码
$ git config --global i18n.logoutputencoding utf-8 # 输出 log 编码
$ export LESSCHARSET=utf-8
# 最后一条命令是因为 git log 默认使用 less 分页,所以需要 bash 对 less 命令进行 utf-8 编码

3、git 导出两个版本之间的增量包
$ git diff 1668f09 e4c9853 --name-only | xargs tar -czvf update.tar.gz

4、本地仓库和远程仓库关联
$ git remote add origin git@xxx.com:xxx/xxx.git
$ git push -u origin master

5、远程下载文件
$ scp root@xxx:/xxx/xxx/2018-01-05.log .

6、如何撤销git add,不小心执行了git add . 操作,但是又不能提交所有的文件,因为对应不同的分支,现在怎么样可以将git add 撤销回来
$ git reset --mixed 这样文件退出暂存区,但是修改保留

posted @ 2018-01-18 17:42  例维亚的杰洛特  阅读(121)  评论(0编辑  收藏  举报