相关疑难解决方法(0)

Mac 和 Windows 的 Git autocrlf 设置

我们的团队有人在 Mac 和 Windows 上工作。到目前为止,我们已将 git 自动行结束设置为true(在 OSX 上)和input(在 Windows 上)。它工作得很好,除非存在合并冲突。在这种情况下,SourceTree 和 GitKraken 都会搞乱 Windows 上的合并,因为它们将所有以 LF 结尾的行视为一行。

我们所有人都应该使用相同的值core.autocrlf(在这种情况下是哪个?)还是针对特定应用程序有一些修复?

注意:目前,当行尾混乱时,我们会进行手动合并,但这很痛苦。另外,设置core.autocrlffalse也不是一个选项,因为配置文件中的错误行结尾会导致 Linux 上的构建崩溃。

windows git macos core.autocrlf

6
推荐指数
1
解决办法
5070
查看次数

如何用Git清理行结尾

我对Git很缺乏经验,这个让我感到困惑:

我只是将我的工作副本切换到另一个分支(一个简单的git checkout master),然后立即git status告诉我有关数百个已更改的文件.然而,这一切都与线路结束有关; a git diff --ignore-space-at-eol给了我很多警告:

warning: CRLF will be replaced by LF in src/.../somefile.js.
The file will have its original line endings in your working directory.
Run Code Online (Sandbox Code Playgroud)

我一般认为在版本化的文本文件中使用DOS样式的行结尾是一个坏主意,但这是他们最初提交的内容; 我在一个Linux机器中完成了这个,我得到的文件有CRLF行结尾.

在我的情况下清理的最佳方法是什么?我应该更改每个文件的行结尾并提交吗?

如何配置Git以避免将来出现这种情况?

git eol

5
推荐指数
1
解决办法
2531
查看次数

进行git隐藏不会删除git local中的更改

当我这样做时git status,我看到一些文件具有本地更改(似乎是缩进更改)。

当我这样做时git stash,它不会从队列中删除这些文件。它阻止我的自动提取脚本从远程git获取。

$ git stash
Saved working directory and index state WIP on develop: 05c60a5 Merge remote-tracking branch 'origin/develop' into develop
HEAD is now at 05c60a5 Merge remote-tracking branch 'origin/develop' into develop

$ git stash
On branch develop 
Your branch and 'origin/develop' have diverged and have 23 and 127 different commit(s) each, respectively.

Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard …
Run Code Online (Sandbox Code Playgroud)

git git-stash

5
推荐指数
1
解决办法
3861
查看次数

新克隆的 git 存储库显示有本地更改

我不太明白,为什么新克隆的 git 存储库显示有更改未提交提交。

这是一个简短的例子:

    [dpetrov@macbook-pro ~/work]$ git clone /tmp/git/pollers.git pollers
    Cloning into 'pollers'...
    done.
    [dpetrov@macbook-pro ~/work]$ cd pollers/
    [dpetrov@macbook-pro ~/work/pollers (master)]$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.

    nothing to commit, working tree clean
    [dpetrov@macbook-pro ~/work/pollers (master)]$ git checkout pollers-1.0
    gBranch pollers-1.0 set up to track remote branch pollers-1.0 from origin.
    Switched to a new branch 'pollers-1.0'
    i
    [dpetrov@macbook-pro ~/work/pollers (pollers-1.0)]$ git status
    On branch pollers-1.0
    Your branch is up-to-date with 'origin/pollers-1.0'.

    Changes not staged for …
Run Code Online (Sandbox Code Playgroud)

git

5
推荐指数
1
解决办法
80
查看次数

为什么'git checkout'仅适用于某些分支机构?

这是两次结账的结果:为什么第二次结账失败?'git status'显示某些文件已被修改,但我确定我没有触及这些文件.

praveensripati@MyMini:~/Hadoop/Git/hadoop-common$ git checkout branch-0.21  
Switched to branch 'branch-0.21'  

praveensripati@MyMini:~/Hadoop/Git/hadoop-common$ git checkout branch-0.20  
error: The following untracked working tree files would be overwritten by checkout:  
    CHANGES.txt  
    LICENSE.txt  
    README.txt  
    bin/hadoop  
    bin/hadoop-daemon.sh  
    bin/hadoop-daemons.sh  
Please move or remove them before you can switch branches.  
Aborting

praveensripati@MyMini:~/Hadoop/Git/hadoop-common$ git status
# On branch trunk
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   CHANGES.txt
#   LICENSE.txt
#   README.txt
#   bin/
#   build.xml
#   conf/
#   lib/ …
Run Code Online (Sandbox Code Playgroud)

git git-checkout

4
推荐指数
1
解决办法
790
查看次数

git post-update脚本不起作用

在编辑了我的旧问题几次之后,我创建了一个新问题,因为它现在是一个新问题.

.git/hooks/post-update我有:

echo "a" >> /home/pi/log
git update-server-info
git stash
git merge testing >> /home/pi/log
Run Code Online (Sandbox Code Playgroud)

进行自动结账.所以我在客户端上运行:

git push testing HEAD:testing
Run Code Online (Sandbox Code Playgroud)

现在我的/home/pi/log包含:

a
Updating ae2f44b..04753a9
Fast-forward
 application/views/main/index.php |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Run Code Online (Sandbox Code Playgroud)

但文件没有改变!

$ git merge testing
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)

如果我删除脚本,进行推送和运行git stash,git merge testing它的工作原理.

更新

为了测试,我将文件中的数字从17更改为20.如果我运行,我可以看到正确的文件版本

git show application/views/main/index.php
Run Code Online (Sandbox Code Playgroud)

vim application/views/main/index.php
Run Code Online (Sandbox Code Playgroud)

仍包含旧号码.但是git声称该文件已更新:

$ git merge testing
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)

git bash

4
推荐指数
1
解决办法
4969
查看次数

git告诉我,我的文件已经更改,但我看不出有任何区别

我刚刚安装了最新的Git(1.9.5),突然它告诉我我的工作树不干净(更改没有上演),但我看不到任何差异工具中任何文件的任何变化(我尝试过Tortoise和Visual Studio的内置功能).当我运行git status时,它说:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   inc/i_lab_orders.asp
        modified:   lab_order_list.asp
        modified:   slib/lab_order_lib.asp
Run Code Online (Sandbox Code Playgroud)

但是,Git GUI的diff工具告诉我所有的行都被改变了,但是我找不到任何区别.与git bash的差异相同.

运行git reset --hard根本没有帮助 - 命令执行没有任何问题,但最后我仍然有相同的"已更改"文件.

更新:core.autocrlf为false,core.fileMode也为false.我还注意到,报告要更改的文件正是在上次提交时提交的文件.

我在Windows上.

git diff tortoisegit

4
推荐指数
1
解决办法
1018
查看次数

将文件提交回GitHub for Windows

我和我的同事正在开发一个Android项目,他最近在https://github.com上设置了一个GitHub回购 .在我的最后,我在我的64位Windows 7机器上下载并安装了GitHub for Windows.然后我继续前往GitHub上的回购并使用"在Windows中克隆"按钮克隆项目.

在Windows中克隆

一切似乎顺利进行,项目进展顺利

C:\Android\git-repos\OurProject
Run Code Online (Sandbox Code Playgroud)

在我的机器上.然后我对文件进行了一些更改

C:\Android\git-repos\OurProject\Host\Android\src\com\ourproject\client\SettingsActivity.java
Run Code Online (Sandbox Code Playgroud)

然后我观察到更改的文件(以及一些更改的构建文件)确实显示在我的机器上的GitHub版本上,就像这样

http://s11.postimage.org/k8o91hq37/changes_on_github.png

我选择了' SettingsActivity.java'文件,填写了一个简短的描述并点击' Commit'按钮.然后我看到了以下屏幕

http://s16.postimage.org/yier6czf9/unsynced_commits.png

然后,当我点击'同步'时

同步

希望我所做的更改将被推回到主仓库,我得到以下消息

unstaged changes
You cannot sync with unstaged changes. Please commit your changes and try again.
Run Code Online (Sandbox Code Playgroud)

为什么我收到此错误消息?

我确实看过这个帖子

github中的非分段更改是什么?

而且似乎必须执行以下步骤

  1. git add
  2. git commit
  3. git push

但是从这个线程

GitHub for Windows的"同步"有什么作用?

可能看起来"同步"按钮会全部三个?所以,我不确定如何准确地提交我的提交.我认为我已经提交了我的更改(在上一步中)意味着我已经将它们上演了,这就是提供同步选项的原因.任何帮助解决这个问题都将非常感激.

PS:我也联系了GitHub支持团队,并在下面发布了他们的解决方案.

git github

3
推荐指数
1
解决办法
5448
查看次数

正则表达式查找 LF lineEndings 并将其修复为 CRLF

类似/相关,但不包括在内:


我主要在 .NET 堆栈中工作,我们希望(几乎)所有文件都是 CRLF。

在我看来,git 永远不应该编辑文件的内容,所以我和我的项目以及我同事的 git 设置是autocrlf=false(即as-is, as-is),请随意就其他问题进行辩论:)

偶尔有人会有错误的 git 设置,或者以其他方式意外地将 LF 引入到 git 存储库中的某些文件中,我想 grep 整个存储库以查找具有 LF 行结尾的文件,然后将它们修复为 CRLF,在逐个文件(以防万一,例如 bash 文件,遗憾的是应该是 LF)。

每次我需要这样做时,我都找不到相关的正则表达式,不得不重新从头开始解决。

所以这个问题的存在是为了记录正确的正则表达式。

regex line-endings

3
推荐指数
1
解决办法
4683
查看次数

将 master 合并到分支时,Git 将整个文件标记为冲突

可能的重复:
git 最好的 CRLF 处理策略是什么?

我目前正在做一个项目,几乎每次我将 master 合并到我的分支时,我都会遇到合并冲突,git 说整个文件都已更改。通常,当我使用 Notepad++ 的比较工具比较这些文件时,它会报告实际上只有几行发生了更改,而且通常甚至不应该导致冲突。

有一段时间我只是把这种行为作为一个在跨平台工作时必须遇到的问题(我们的团队使用 Windows 7、OSX 和 debian 的混合进行开发),但是今天当我合并时,有一些阻碍我前进的严重问题。我自己研究过这个问题,似乎它可能与 git core.autocrlf 配置有关,但我不确定如何解决这个问题,以便它立即消失,或者随着 git 修复损坏而慢慢消失我以前做过。任何人都可以就如何解决这个问题提出任何建议吗?

谢谢,
亚历克斯

git cross-platform git-merge

2
推荐指数
1
解决办法
4067
查看次数