簡體   English   中英

如何在無業游民的VM中使用cygwin,git bash和git在Windows上設置git?

[英]How to setup git on windows with cygwin, git bash and git in a vagrant VM?

我的設定

我們正在使用Windows 10。 我的任務是使用我們都想使用的Vagrant構建開發VM。

我們正在通過Vagrant SSH掛載將git文件夾掛載到VM中,該掛載目前非常完美。

我們還將Visual Studio Code用作編輯器。

我的目標

我想在cygwin中(對於Windows用戶)使用git,並在VM中無縫使用git。

當然,我們希望使用Visual Studio代碼的功能來突出顯示已更改的文件。 據我了解,Visual Studio Code是使用git bash中的git實現。 但這是次要條件。

我的配置

在所有機器上,我都有以下.gitconfig

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

我的問題

我克隆了一個回購協議,而sh​​ell向我展示了不同的輸出

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流浪者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)]$

我的.gitattributes在此倉庫中

* text=auto

我應該如何設置我的gitconfigs?

我讀了很多文章,花了很多時間,但是我仍然對如何設置環境感到困惑。

有人可以幫我嗎?

首先,Cygwin不是唯一的選擇: WSL(Linux的Windows子系統)是另一個選擇,它將提供真正的類似於Linux的體驗。

其次,如前所述,在Vagrant中需要git config --global core.fileMode false來忽略chmod。

但是第三,對於您知道要用+ x(755而不是644)記錄的文件,而不考慮操作系統( 例如Windows ,它將忽略執行權限),鍵入( 使用Git 2.9.1+ ):

git add --chmod=+x -- afile

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM