如何在无业游民的VM中使用cygwin,git bash和git在Windows上设置git? [英] How to setup git on windows with cygwin, git bash and git in a vagrant VM?

查看:125
本文介绍了如何在无业游民的VM中使用cygwin,git bash和git在Windows上设置git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Windows 10. 我的任务是使用我们都想使用的Vagrant构建开发VM.

We are using Windows 10 at work. I had the task to build a development VM with Vagrant which we all want to use.

我们正在通过Vagrant SSH挂载将git文件夹挂载到虚拟机中,

We are mounting our git folders into the VM via the Vagrant SSH mount which works perfect for now.

我们还将Visual Studio Code用作编辑器.

We are also using Visual Studio Code as Editor.

我想在cygwin(对于Windows用户)中使用git,并在VM中无缝使用git.

I want to use git in cygwin (for the windows users) and git in the VM seamlessly.

当然,我们希望使用Visual Studio代码的功能来突出显示已更改的文件.据我了解,Visual Studio Code正在使用git bash中的git实现. 但这是次要条件.

And of course we want to use the feature of Visual studio code to hightlight the changed files. As I understand it right Visual Studio Code is using the git implementation from the git bash. But this is a secondary requirement.

在所有计算机上,我都有以下 .gitconfig :

On all machine I have the following .gitconfig:

[core]
    autocrlf = input
    editor = vim
    eol = lf
    filemode = false

我的问题

我克隆了一个回购协议,而sh​​ell向我展示了不同的输出

My Problem

I clone a repo and the shells show me differnt outputs

git bash :

pwd
/c/Users/user/git/docker-install
>git status
On branch master
Your branch is up to date with 'origin/master'.

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:   .gitattributes

no changes added to commit (use "git add" and/or "git commit -a")
>git diff
diff --git a/.gitattributes b/.gitattributes
old mode 100755
new mode 100644

cygwin :

user@machine /cygdrive/c/Users/user/git/docker-install
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

user@machine /cygdrive/c/Users/user/git/docker-install
$ git diff

user@machine /cygdrive/c/Users/user/git/docker-install
$

Git流浪者虚拟机:

[vagrant@vagrant docker-install (⎈ |minikube:default)]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
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:   .gitattributes

no changes added to commit (use "git add" and/or "git commit -a")
[vagrant@vagrant docker-install (⎈ |minikube:default)]$ git diff
diff --git a/.gitattributes b/.gitattributes
old mode 100755
new mode 100644
[vagrant@vagrant docker-install (⎈ |minikube:default)]$

我的.git归入此仓库

* text=auto

我读了很多文章,花了很多时间,但是我仍然很困惑如何设置环境.

I read a lot of articles, spend a lot of time but I am still confused how we should setup our environment.

有人可以帮我吗?

推荐答案

首先,Cygwin不是唯一的选择:

First, Cygwin is not the only option: WSL (Windows Subsystem for Linux) is another option which would offer a true Linux-like experience.

第二,如前所述,Vagrant需要 git config --global core.fileMode false 来忽略chmod.

Second, as noted, git config --global core.fileMode false is needed in Vagrant to ignore chmod.

但是,第三,对于您知道要使用+ x(755而不是644)进行记录的文件,而与操作系统无关(例如在Windows 中,它将忽略执行权限),请键入(使用Git 2.9.1+ ):

But third, for files you know you want to be recorded with +x (755 instead of 644), irrespective of the OS (like in Windows, which would ignore the execute permission), type (with Git 2.9.1+):

git add --chmod=+x -- afile

这篇关于如何在无业游民的VM中使用cygwin,git bash和git在Windows上设置git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆