git报错 fatal: unsafe repository 解决方法 xxx is owned by someone else

原文:https://www.aspirantzhang.com/network/git-fatal-unsafe-repository.html

git近期进行了版本升级,添加了新的目录安全限制。造成在进行git常规操作时,或在各类编辑器如VSCode中无法发现.git文件,报错:

fatal: unsafe repository(xxx is owned by someone else.)
To add an exception for this directory, call
git config –global –add safe.directory

本文介绍处理方法。

处理方案1:忽略单个目录

哪个目录里有git,就通过命令行添加哪个目录,多个目录,多次添加。

git config --global --add safe.directory D:/www/your-project
git config --global --add safe.directory D:/www/other-project

处理方案2:忽略全部文件夹

可以通过加通配符为*,忽略所有文件夹。需要注意,该处理方法一般适用于只有本人一个用户使用的电脑,确保无其它用户,否则存在安全问题。见下方详述。

git config --global --add safe.directory "*"

一个项目设置两个git地址,并最终实现一次性同时推送到到两个git地址上

原文地址:https://www.cnblogs.com/teamemory/p/11607613.html

基于多处备份的想法,确保自己的代码不丢失。或者是代码的git本身搭建在自己公司的服务上,而你为了保险起见,想把项目同时放在码云或者github上面。
这样,你就需要让一个项目同时备份在两个云端,这样即使公司的服务器上面的代码丢了,或者公司服务器把你的名单除名了,你仍然在码云或者github上面存有你的代码。
那么,怎么实现这个想法呢?请看如下步骤:

前提:

1、假设你现在在gitLab上面新建了一个git地址A(里面已经有项目内容)

git@git.taotiangou.net:teamemory/myh5.git

2、假设你同时在码云上面同样新建了一个git地址B (可能是一个新建的空白项目内容地址)

git@gitee.com:teamemory/myH5.git

现在想实现我在git地址A项目中,提交代码的同时,可同时提交到git地址B 。

方法1:(需要push两次,不符合题目要求,但是优点是可以pull两次)

步骤1:
在git A 项目中添加另一个git B远程的地址

git remote add origin2 git@gitee.com:teamemory/myH5.git    // origin2可以自定义

步骤2:
先拉取git B 该地址上的数据

git pull origin2 master --allow-unrelated-histories   (--allow-unrelated-histories是为了解决冲突)

步骤3:
在git A 项目中把项目内容同步到git B地址中

git push origin2 master

此时,我们基本实现了可以把一个项目可以提交到两个git地址了,但是每次提交内容都需要进行如下两次提交,才能实现把一个项目同时提交到两个git地址。

git push origin  master
git push origin2 master

问题来了,我们想要的实现的是,我提交一次,就能同步两个项目,怎么继续实现呢?请看方法2
注意:删除上面的添加的git B的远程地址

git remote -v  // 查看此时的包括两个远程地址
git remote rm origin2  // 删除git B的远程地址
git remote -v  //此时应该只有git A的远程地址

方法2:(只需要push一次)

给origin 增加一个可以push的地址

git remote set-url --add origin git@gitee.com:teamemory/myH5.git   //给origin添加一个远程push地址,这样一次push就能同时push到两个地址上面
git remote -v //查看是否多了一条push地址(这个可不执行)

至此,我们就可以直接一个push,同时推送到两个git地址。

git push origin master -f    // 如果第一次推不上去代码,可以使用强推的方式

注意:删除添加的路径的方法是

git remote set-url --delete origin git@gitee.com:teamemory/myH5.git

至此,我们建议一次push实现两个git项目的沟通,建议使用方法2!!!

设置 DialogFragment 的背景颜色透明

原文:https://blog.csdn.net/cc20032706/article/details/51741793
Android 开发中,能否设置 DialogFragment 的背景颜色?
系统默认的过于深了,非常不友好。

解决方案:
1.在DialogFragment的onCreateView里面设置,可以将对话框内部的背景设为透明

getDialog().getWindow().setBackgroundDrawable(newColorDrawable(Color.TRANSPARENT));

2.在DialogFragment的onstart里面设置,可以将对话框外部的背景设为透明

@Override
public void onStart() {
    // TODO Auto-generated method stub
    super.onStart();        
    Window window = getDialog().getWindow();
    WindowManager.LayoutParams windowParams = window.getAttributes();
    windowParams.dimAmount = 0.0f;
    window.setAttributes(windowParams);
}

————————————————
版权声明:本文为CSDN博主「摄氏三十七度」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/cc20032706/article/details/51741793

实测方案1 好用,收藏一下

Android:ClassNotFoundException:Didn't find class "org.apache.http.util.Args"

原文链接:https://blog.csdn.net/qq_33721320/article/details/86620524

在 Android 6.0 中,我们取消了对 Apache HTTP 客户端的支持。 从 Android 9 开始,默认情况下该内容库已从 bootclasspath 中移除且不可用于应用。

要继续使用 Apache HTTP 客户端,以 Android 9 及更高版本为目标的应用可以向其 AndroidManifest.xml的###application节点下 添加以下内容:
<uses-library
    android:name="org.apache.http.legacy"
    android:required="false" />

在application下面添加 uses-library。即可

        <application
            android:name=".MyApp"
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:usesCleartextTraffic="true"
            android:theme="@style/AppTheme">
 
            <uses-library
                android:name="org.apache.http.legacy"
                android:required="false" />
 
            <activity
                android:name=".activity.SplashActivity"
                android:exported="true"
                android:screenOrientation="portrait"
                android:theme="@style/Splash">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
 
                    <category android:name="android.intent.category.LAUNCHER" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
 
        </application>
<!--android:usesCleartextTraffic="true"主要是适配9.0的Http网络请求。-->

注:拥有最低 SDK 版本 23 或更低版本的应用需要 android:required="false" 属性,因为在 API 级别低于 24 的设备上,org.apache.http.legacy 库不可用。 (在这些设备上,Apache HTTP 类在 bootclasspath 中提供。)
作为使用运行时 Apache 库的替代,应用可以在其 APK 中绑定自己的 org.apache.http 库版本。 如果进行此操作,您必须将该库重新打包(使用一个类似 Jar Jar 的实用程序)以避免运行时中提供的类存在类兼容性问题。