“IDEA:Git相关”的版本间差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
| 第42行: | 第42行: | ||
== 关于:Shelve、Stash ==  | == 关于:Shelve、Stash ==  | ||
  参见:<big>'''[https://www.jetbrains.com/help/idea/work-on-several-features-simultaneously.html IDEA_Doc:work-on-several-features-simultaneously]'''</big>  |   参见:<big>'''[https://www.jetbrains.com/help/idea/work-on-several-features-simultaneously.html IDEA_Doc:work-on-several-features-simultaneously]'''</big>  | ||
 '''Stash'''(保存工作现场)与 '''Shelve'''(搁置):  | |||
 1、Stash 由 git 生成,可以由 IDEA 或其他方式使用;  | |||
    Shelve 由 IDEA 生成,由 IDEA 使用。  | |||
 2、Stash 将保存所有 uncommitted changes;  | |||
    Shelve 可以选择保存部分 uncommitted changes。  | |||
Shelve:  | |||
== 关于:“强制推送” ==  | == 关于:“强制推送” ==  | ||
2022年5月27日 (五) 16:58的版本
关于:merge、rebase、cherry-pick、应用独立更改、应用独立文件
参见:IDEA_Doc: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”):
 
关于:Shelve、Stash
参见:IDEA_Doc:work-on-several-features-simultaneously Stash(保存工作现场)与 Shelve(搁置): 1、Stash 由 git 生成,可以由 IDEA 或其他方式使用; Shelve 由 IDEA 生成,由 IDEA 使用。 2、Stash 将保存所有 uncommitted changes; Shelve 可以选择保存部分 uncommitted changes。
Shelve:
关于:“强制推送”
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 测试: