“IDEA:Git相关”的版本间差异
跳到导航
跳到搜索
第13行: | 第13行: | ||
# Apply separate files(应用独立文件,[[File:IDEA:icons:get.svg]]):将某个 commit 的 files 应用到当前分支,会反应在 ChangeList 中。 | # Apply separate files(应用独立文件,[[File:IDEA:icons:get.svg]]):将某个 commit 的 files 应用到当前分支,会反应在 ChangeList 中。 | ||
#: [[File:IDEA:Git:Apply separate files.png|600px]] | #: [[File:IDEA:Git:Apply separate files.png|600px]] | ||
== 关于:Resolve conflicts(冲突解决) == | |||
参见:<big>'''[https://www.jetbrains.com/help/idea/resolve-conflicts.html IDEA_DOC:resolve-conflicts]'''</big> | |||
注: | |||
# “Non-Conflicting Changes”:仅在左侧(或右侧)新增、修改、删除的冲突内容; | |||
#* 可以通过:[[File:IDEA:icons:Apply All Non-Conflicting Changes.svg]]、[[File:IDEA:icons:Apply Non-Conflicting Changes from the Left Side.svg]]、[[File:IDEA:icons:Apply Non-Conflicting Changes from the Right Side.svg]] 来快速解决。 | |||
# “Conflicting Changes”:同时在左右两侧修改过的冲突内容; | |||
#* 手动确定决解方案。 | |||
=== 关于:行末标识冲突 === | |||
行末标识符:<big>'''LF'''</big>(Unix, Linux and MacOS),<big>'''CRLF'''</big>(Windows) | |||
解决: | |||
# 全局设置(通过命令): | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
# on Windows | |||
git config --global core.autocrlf true | |||
# on Linux and macOS | |||
git config --global core.autocrlf input | |||
</syntaxhighlight> | |||
# 仓库设置(通过配置文件“.gitattributes”): | |||
# 参见:'''[https://docs.github.com/cn/get-started/getting-started-with-git/configuring-git-to-handle-line-endings Github_DOC:configuring-git-to-handle-line-endings]''' | |||
== 关于:Shelve、Stash == | == 关于:Shelve、Stash == | ||
参见:<big>'''[https://www.jetbrains.com/help/idea/work-on-several-features-simultaneously.html | 参见:<big>'''[https://www.jetbrains.com/help/idea/work-on-several-features-simultaneously.html IDEA_DOC:work-on-several-features-simultaneously]'''</big> | ||
== 关于:“强制推送” == | == 关于:“强制推送” == |
2022年5月27日 (五) 16:34的版本
关于:merge、rebase、cherry-pick、应用独立更改、应用独立文件
参见:apply-changes-from-one-branch-to-another
- merge:
- rebase:
- cherry-pick
:将某个 commit 应用到当前分支,会在 HEAD 新增一个 commit。
- 中文插件翻译为“优选”。
- Apply separate changes(应用独立更改):将某个 commit 的 changes 应用到当前分支,会反应在 ChangeList 中。
- Apply separate files(应用独立文件,
):将某个 commit 的 files 应用到当前分支,会反应在 ChangeList 中。
关于:Resolve conflicts(冲突解决)
参见:IDEA_DOC:resolve-conflicts
注:
- “Non-Conflicting Changes”:仅在左侧(或右侧)新增、修改、删除的冲突内容;
- “Conflicting Changes”:同时在左右两侧修改过的冲突内容;
- 手动确定决解方案。
关于:行末标识冲突
行末标识符:LF(Unix, Linux and MacOS),CRLF(Windows)
解决:
- 全局设置(通过命令):
# on Windows git config --global core.autocrlf true # on Linux and macOS git config --global core.autocrlf input
- 仓库设置(通过配置文件“.gitattributes”):
- 参见:Github_DOC:configuring-git-to-handle-line-endings
关于:Shelve、Stash
参见:IDEA_DOC:work-on-several-features-simultaneously
关于:“强制推送”
Git 的“强制推送”(git push --force-with-lease):强制推送本地分支到远程,将会忽略远程分支版本比本地高【即,抛弃比当前 commit 更高版本的 commit】;
【慎用!!!】
示例:
不能使用“强制推送”?
IDEA 不能对“受保护分支”(Git 相关设置中)进行强制推送。
“受保护分支”设置:
- 如上,删除或更改此处设置,则可以对 master 分支进行强制推送了。
FAQ
推送错误:“git@github.com: Permission denied (publickey).”
使用 IDEA 推送本地仓库到 GitHub 时,遇到错误:“git@github.com: Permission denied (publickey).”
错误信息:
- IDEA git:
- ssh 测试:
- ssh -T git@github.com:用于测试 SSH 到 GitHub 是否可用;
- ssh -vT git@github.com:用于测试 SSH 到 GitHub 是否可用,并会显示详细信息;
原因:推送到 GitHub 需要 SSH,当前未配置相关内容。
解决:
- 本地:
- 生成 SSH 密钥对:
- 由于本地已存储了其他密钥对(“id_rsa、id_rsa.pub”),所以此处修改了存储文件名;
- 新建 config 文件:
- 由于修改了密钥文件的名称(或位置),所以需要 config 文件(C:\Users\eijux\.ssh\)进行配置;
# github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile C:\\Users\\eijux\\.ssh\\id_rse_github
- 生成 SSH 密钥对:
- Github:配置 SSH keys。
- SSH 测试: