[英]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
我克隆了一个回购协议,而shell向我展示了不同的输出
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)]$
* text=auto
我读了很多文章,花了很多时间,但是我仍然对如何设置环境感到困惑。
有人可以帮我吗?
首先,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.