Git diff在Android Studio中无法正常工作?

时间:2018-11-22 07:13:13

标签: git android-studio

在我的Android Studio中,更改某行中的文本会在diff中显示整个文件。以前,这可以正常工作;现在不起作用。

我对设置进行了多次更改,所以我无法确定罪魁祸首。我在Android Studio中添加了自己的格式化程序-不知道这是否引起了问题。

下面我附加了示例git diff输出:

@@ -1 +1 @@
-package com.gyanapp.Base;^Mimport android.os.Bundle;^Mimport android.support.annotation.Nullable;^Mimport com.AppVersionModel;^Mimport com.OTPApi;^Mimport com.gyanapp.Screens.ForceUpgrade.Forc
eUpgradeScreen;^Mimport com.gyanapp.Utils.DeviceUtils;^Mimport com.gyanapp.Utils.NetWorkUtil;^Mimport io.reactivex.android.schedulers.AndroidSchedulers;^Mimport io.reactivex.observers.Disposabl
eObserver;^Mimport io.reactivex.schedulers.Schedulers;^M/**^M * Created by Utkarsh Shukla on 03/11/18.^M */^Mpublic abstract class BaseForceUpdradeCheck extends BaseActivity {^M    @Override^M 
   public  abstract void logScreenFlowEventForAnalytics() ;^M    @Override^M    protected void onCreate(@Nullable Bundle savedInstanceState) {^M        super.onCreate(savedInstanceState);^M    
    DisposableObserver<AppVersionModel> disposableObserver =^M                new DisposableObserver<AppVersionModel>() {^M                    @Override^M                    public void onNext(
AppVersionModel appVersionModel) {^M                        if (DeviceUtils.requireForceUpgrade(appVersionModel)) {^M                            startActivity(ForceUpgradeScreen.createIntent(Ba
seForceUpdradeCheck.this));^M                            finish();^M                        } else {^M                            continueNormalProcess();^M                        }^M//        
                continueNormalProcess();^M                    }^M                    @Override^M                    public void onError(Throwable e) {^M                    }^M                    @Override^M                    public void onComplete() {^M                    }^M                };^M        DisposableObserver<AppVersionModel> homeResponseDisposableObserver =^M                NetWorkUtil.provideRetrofit().create(OTPApi.class).checkAppVersion()^M                        .subscribeOn(Schedulers^M                                .io())^M                        .observeOn(AndroidSchedulers.mainThread())^M                        .subscribeWith(disposableObserver);^M    }^M    protected abstract void continueNormalProcess();^M}
\ No newline at end of file
+package com.gyanapp.Base;^Mimport android.os.Bundle;^Mimport android.support.annotation.Nullable;^Mimport com.AppVersionModel;^Mimport com.OTPApi;^Mimport com.google.firebase.perf.FirebasePerformance;^Mimport com.google.firebase.perf.metrics.Trace;^Mimport com.gyanapp.Screens.ForceUpgrade.ForceUpgradeScreen;^Mimport com.gyanapp.Utils.Config;^Mimport com.gyanapp.Utils.DeviceUtils;^Mimport com.gyanapp.Utils.NetWorkUtil;^Mimport io.reactivex.android.schedulers.AndroidSchedulers;^Mimport io.reactivex.observers.DisposableObserver;^Mimport io.reactivex.schedulers.Schedulers;^M/**^M * Created by Utkarsh Shukla on 03/11/18.^M */^Mpublic abstract class BaseForceUpdradeCheck extends BaseActivity {^M    @Override^M    public  abstract void logScreenFlowEventForAnalytics() ;^M    @Override^M    protected void onCreate(@Nullable Bundle savedInstanceState) {^M        super.onCreate(savedInstanceState);^M        Trace myTrace = FirebasePerformance.getInstance().newTrace(Config.TRACE.SPLASH_FORCE_UPGRADE_CHECK_CALL);^M        myTrace.start();^M        DisposableObserver<AppVersionModel> disposableObserver =^M                new DisposableObserver<AppVersionModel>() {^M                    @Override^M                    public void onNext(AppVersionModel appVersionModel) {^M                        myTrace.incrementMetric(Config.TRACE.SPLASH_FORCE_UPGRADE_CHECK_CALL_SUCCESS,1);^M                        myTrace.stop();^M                        if (DeviceUtils.requireForceUpgrade(appVersionModel)) {^M                            startActivity(ForceUpgradeScreen.createIntent(BaseForceUpdradeCheck.this));^M                            finish();^M                        } else {^M                            continueNormalProcess();
^M                        }^M                    }^M                    @Override^M                    public void onError(Throwable e) {^M                        myTrace.incrementMetric(Config.TRACE.SPLASH_FORCE_UPGRADE_CHECK_CALL_ERROR,1);^M                        myTrace.stop();^M                    }^M                    @Override^M                    public void onComplete() {^M^M                    }^M                };^M        DisposableObserver<AppVersionModel> homeResponseDisposableObserver =^M                NetWorkUtil.provideRetrofit().create(OTPApi.class).checkAppVersion()^M                        .subscribeOn(Schedulers^M                                .io())^M                        .observeOn(AndroidSchedulers.mainThread())^M                        .subscribeWith(disposableObserver);^M    }^M    protected abstract void continueNormalProcess();^M}^M
\ No newline at end of file

ˆM是什么?什么是No newline at end of file

尝试了this,但没有成功

1 个答案:

答案 0 :(得分:0)

右下角有一个选项可以更改Android Studio中的行分隔符。请参见下面的图片。

在某些格式中,我错误地将行分隔符更改为CR并提交了。然后ˆM问题出现在我提交的每个文件中。

我将选项更改为LF并再次提交了每个文件,现在已解决。

enter image description here