简体   繁体   English

Git回购叉和从原始回购更新

[英]Git Repo Fork and Updating from Original Repo

How can I update my modified fork of a git repo if the original repo has a different format for things like whitespacing? 如果原始存储库对whitespacing之类的格式有不同的格式,我该如何更新git存储库的修改后的fork?

This is the repo that I have forked: Original Repo 这是我分叉的仓库原始仓库

They space like this: 他们的空间像这样:

for ( final ListenerInfo info : config.getListeners() )

Where I would instead space: 我将在哪里放置空间:

for (final ListenerInfo info : config.getListeners())

As well as this, the original repo uses 4 spaces to indent where as my modified fork uses tab. 除此之外,原始仓库使用4个空格来缩进我修改后的fork使用tab的位置。

It's difficult to merge the changes because almost everything comes up in the diff due to the extra spaces. 合并更改很困难,因为由于多余的空间,几乎所有内容都出现在差异中。

I could not have this issue if I changed my IDE format settings to space like their project, but I don't care for the look of the extra spacing. 如果我将IDE格式设置更改为像他们的项目那样的空间,就不会出现此问题,但是我不在乎多余间距的外观。

You can use locally the space convention that you want, but you need to make sure you check in only code which respects the space convention of the original repo (like a git clean filter driver which could try and call the Eclipse formatter from the command line ). 您可以在本地使用所需的空间约定,但是需要确保仅签入遵守原始存储库空间约定的代码(例如git clean筛选器驱动程序 ,可以尝试从命令行调用Eclipse格式化程序) )。

<path-to-eclipse>\eclipse.exe -vm <path-to-vm>\java.exe \
  -application org.eclipse.jdt.core.JavaCodeFormatter \
  -verbose \
   -config <path-to-config-file>\org.eclipse.jdt.core.prefs <path-to-your-source-files>\*.java

Unless you can convince the original repo to adopt your convention, it is best to not touch anything in a project you want to contribute back to. 除非您可以说服原始存储库采用您的约定,否则最好不要触摸您想要回馈的项目中的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM