git 使用记录



补丁生成-diff和patch的使用

生成补丁

1
git diff > test.patch

应用补丁

检查patch/diff文件

1
git apply --stat xxx.patch

检查能否应用成功

1
git apply --check xxx.patch

打补丁

1
git apply xxx.patch

删除分支

删除本地分支

删除本地分支命令

1
git branch -d [local_branch_name]
  • git branch 是在本地删除分支的命令

  • -d 是一个标志,是命令的一个选项,它是`--delete`的别名。顾名思义,它表示你要删除某些内容。

  • local_branch_name 是要删除的分支的名称

删除远程分支

删除远程分支

1
git push remote_name -d [remote_branch_name]
  • 你可以使用`git push`命令删除远程分支,而不是使用用于本地分支的`git branch`命令。

  • 然后指定远程的名称,在大多数情况下是`origin`。

  • -d`是删除的标志,是--delete`的别名。

  • `remote_branch_name`是你要删除的远程分支。

删除远程分支示例

查看远程分支

1
2
3
4
5
$ git branch -a
* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
  remotes/origin/master

-a`标志(--all`的别名)显示所有分支—​本地和远程 可以看出有两个远程分支`origin/master`和`origin/main` -r`是--remotes`的别名,仅显示远程仓库

删除远程`origin/master`分支

1
2
3
$ git push origin -d master
To https://xxx.com/gituser/test.git
 - [deleted]         master

换行符问题

1
2
3
4
5
6
7
8
# 提交时 CRLF 转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

# 提交时 CRLF 转换为LF,检出时不做任何的转换
git config --global core.autocrlf input

# 提交和检出均不做任何的转换
git config --global core.autocrlf false

words558
tagsgit
lastmod2023-07-09
footer test line hide