2

My Setup

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

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

We are also using Visual Studio Code as Editor.

My Goal

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

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.

My config

On all machine I have the following .gitconfig:

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

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 VM:

[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)]$

My .gitattributes in this this repo

* text=auto

How should I setup my gitconfigs?

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

Can someone help me on this one?

ajfriesen
  • 67
  • 8
  • Is this any help? It suggests the fileMode option is case sensitive. https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes – Jon Jun 04 '18 at 11:17
  • I can not verify since a week after that questions I switched back to Linux. – ajfriesen Nov 08 '20 at 21:02

1 Answers1

0

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

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

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • As stated above in the comments. After a week or so I just switched back to Linux. Just the tool I am comfortable with. Therefore can not verify anymore. – ajfriesen Nov 08 '20 at 21:03
  • @ajfriesen Linux is an excellent choice ;) But I have written this answer more than two years ago, when you originally asked the question. So I could not have read your comment then. – VonC Nov 08 '20 at 21:05