GIT 学习笔记

Git 本地仓库仓库 远程连接http -> ssh

1
2
3
4
5
6
# 查看远程仓库类型
git remote -v
# 修改远层仓库
git remote rm origin
git remote add origin git@xxx/ios.git
git push origin xxx

windows 下IDEA 配置 terminal为git

  • bash 终端配置
    • 启动bash
    • 调出属性界面
    • 在选项tab栏中勾选使用旧版控制台
  • idea terminal 改为bash.exe
  • 重启电脑

windows下中文乱码问题:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Windows系统下GitBash显示的中文乱码解决方案
在git 安装目录 etc 下面 添加以下配置信息

1,/etc/gitconfig:

  [gui]

  encoding = utf-8 #代码库统一用urf-8,在git gui中可以正常显示中文

  [i18n]

  commitencoding = GB2312 #log编码,window下默认gb2312,声明后发到服务器才不会乱码

  [svn]

  pathnameencoding = GB2312 #支持中文路径

2,/etc/git-completion.bash:

  alias ls='ls --show-control-chars --color=auto' #ls能够正常显示中文

3,/etc/inputrc:

  set output-meta on #bash中可以正常输入中文

  set convert-meta off

4,/etc/profile:

  export LESSHARSET=utf-8 #$ git log 命令不像其它 vcs 一样,n 条 log 从头滚到底,它会恰当地停在第一页,按 space 键再往后翻页。这是通过将 log 送给 less 处理实现的。以上即是设置 less 的字符编码,使得 $ git log 可以正常显示中文。



PS:经过实践建议更改如下:

commitencoding =utf-8

pathnameencoding = utf-8

这样更改:gitbash中文显示正常,并且TortorseGit软件中文也会显示正常,不然两个软件会有中文显示的冲突,其中一个软件的中文会有问题。

GIT 不常用命令梳理

1、将本地项目推送至远程

1
git push -u orgin feature/my-feature

2、打标签

1
git tag -a <version> -m '打标签信息'

3、删除远程分支

1
git push -f origin :feature/data-migration

4、将远程删除的分支同步到本地

1
git remote prune origin

5、永久删除某个文件的log历史记录

1
2
git filter-branch -f --tree-filter 'rm -rf note-doc/note-personal/note-scret/ubuntu配置信息.md' HEAD 
git push origin -f