..

git 使用记录

//// url: ba4228a4 ////

== 补丁生成-diff和patch的使用

=== 生成补丁

git diff > test.patch

=== 应用补丁

检查patch/diff文件

git apply --stat xxx.patch

检查能否应用成功

git apply --check xxx.patch

打补丁

git apply xxx.patch

== 删除分支

=== 删除本地分支

删除本地分支命令

git branch -d [local_branch_name]
  • git branch 是在本地删除分支的命令
  • -d 是一个标志,是命令的一个选项,它是--delete的别名。顾名思义,它表示你要删除某些内容。
  • local_branch_name 是要删除的分支的名称

=== 删除远程分支

删除远程分支

git push remote_name -d [remote_branch_name]
  • 你可以使用git push命令删除远程分支,而不是使用用于本地分支的git branch命令。
  • 然后指定远程的名称,在大多数情况下是origin
  • -d是删除的标志,是--delete的别名。
  • remote_branch_name是你要删除的远程分支。

删除远程分支示例

查看远程分支

$ git branch -a
* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
  remotes/origin/master

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

删除远程origin/master分支

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

== 换行符问题

# 提交时 CRLF 转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

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

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