Git 使用报错集

Git 使用报错集

Git在实际的使用过程中会遇到很多实际问题,下面对这些问题做一一分析和解决。

目录:

  1. no new change问题;

  2. unpacker error问题;

  3. 中文乱码(ls -all);

  4. 中文乱码(git status);

  5. 推送代码是出现以下问题:

! [remote rejected] master -> refs/for/master (no new changes)

问题分析:Git bash提示:no new changes表示没有新的提交。Gerrit根据commit id和changeId判断是否有新的提交,如果以上两者都是相同的,则Gerrit会拒绝提交。解决办法:git commit --amend生成新changeId。

  1. 仍然是push代码时出现的问题
! [remote rejected] HEAD -> refs/for/k26s/ld/a107c (n/a (unpacker error))

解决方案:

$ git push --no-thin origin HEAD:refs/for/k26s/ld/a107c

在push指令中,添加参数: --no-thin。

  1. Windows平台下使用Git Bash显示中文出现乱码。

具体现象如下:

Administrator@ZHANGFENG /f/sptSrcGit/CarDoc (master)
$ ls
old_document  ??????????????????

输入以下指令即可:

$ alias ls='ls --show-control-chars --color=auto'
  1. Windows平台下使用Git Bash时,执行 git status 时显示中文乱码问题:

yaya@yaya-PC MINGW64 /d/GitWorkspace/AndroidDemos/HandlerDemo (master)

$ git st

On branch master

Your branch is up-to-date with 'origin/master'.

Untracked files:

  (use "git add <file>..." to include in what will be committed)

 

        .gitignore

        "\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt"

 

nothing added to commit but untracked files present (use "git add" to track)

</file>

解决办法:

git config --global core.quotepath false
  1. Windows平台下,提交代码出现以下提示内容:

yaya@yaya-PC MINGW64 /d/GitWorkspace/OpenSourceProjects (master)

$ git add .

warning: LF will be replaced by CRLF in AndroidIoT/gradlew.

The file will have its original line endings in your working directory.

究其原因:Windows平台下使用回车和换行符(CRLF)作为结束标志,Linux/Mac以换行符作为结束标志(LF)。

声明:本内容借鉴于http://www.cnblogs.com/CVstyle/p/6188022.html 详细请查看原文章

posted @ 2022-12-06 22:22  轻风细雨_林木木  阅读(27)  评论(0编辑  收藏  举报