Git相关问题

git status中文文件名乱码问题

1
2
3
4
5
6
7
8
9
10
$ git status
On branch master
Initial commit

Untracked files:
(use "git add <file>..." to include in what will be committed)

"\345\237\272\345\234\260.txt"

nothing added to commit but untracked files present (use "git add" to track)

解决办法:

  • 命令行中执行:git config --global core.quotepath false
  • 直接修改~/.gitconfig文件,在[core]区加入quotepath = false
1
2
3
[core]
excludesfile = /Users/xxx/.gitignore_global
quotepath = false

使用代理

针对httphttps协议:

1
git clone -c http.proxy=http://127.0.0.1:1087 https://chromium.googlesource.com/libyuv/libyuv

全局配置:

1
2
3
4
5
6
7
git config --global http.proxy 'socks5://127.0.0.1:1087'

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

git config --global http.proxy 'http://127.0.0.1:12333'

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

针对git协议:

1
git config core.gitProxy  'socks5://192.168.7.1:1080'

不再对某文件进行版本控制

不再对曾经被push到代码仓库中的某文件进行版本控制

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch ${path_to_file}" HEAD

其中的${path_to_file},为指定的某个文件(版本库相对路径)

补丁文件

生成patch

不包括 qaz 这个 commit

git format-patch --output-directory=/x/y/z qaz..wsx

应用patch

git am xyz.patch

如果打补丁失败,可以使用三路合并,手动处理冲突:

git am -3 xyz.patch


Git相关问题
https://daniate.github.io/2019/11/02/Git相关问题/
作者
Daniate
发布于
2019年11月2日
许可协议