在Windows上使用Git将symlink文件添加为文件 [英] Add symlink file as file using Git on Windows

查看:355
本文介绍了在Windows上使用Git将symlink文件添加为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git中有一个很大的(超过1000个文件)VS C#项目.我需要创建一个小型演示项目,并使用该大型项目中的十个文件.为了创建这个新项目,我从大项目到小项目添加了十个带有mklink(符号链接)的文件.大型项目和小型项目中相应文件中的所有更改都是相同的.现在,我需要将小项目添加到另一个(我自己的)git repo中.

I have a big (more than 1000 files) VS C# project in git. I need to create a small demo project and use ten files from the big project. To create this new project, I added ten files with mklink (symlink) from the big project to the small. All changes in corresponding files in the big and small project are identical. Now I need to add the small project to a different (my own) git repo.

但是symlink不会添加到git中:

But symlink will not add in git :

(错误:readlink("X.cs"):未实现功能)

(error: readlink("X.cs"): Function not implemented)

如何在git中将X.cs(符号链接)文件添加为常规文件?

How to add the X.cs (symlink) file in git as a regular file?

我需要将X.cs(在大项目中)的所有更改都移到X.cs(小项目)中.

I need all changes in X.cs (in big project) to be moved to X.cs (small project).

推荐答案

git的单个文件链接有问题,但目录符号链接(mklink/d)没有问题.因此,将图像文件移动到大项目中的另一个目录,并在git repo中创建指向该目录的目录链接.

git has problems with individual file links but it has no problem with directory symbolic links(mklink /d ). Therefore move your image files to another directory in your big project and create directory link in your git repo to this directory.

例如,请参见下文.

P:\ denemeler \ gitdeneme1> mklink/d link目录P:\ puzzles

P:\denemeler\gitdeneme1>mklink /d linkDirectory P:\puzzles

创建的符号链接:linkDirectory<< === >> P:\拼图

Created symbolic link : linkDirectory <<===>> P:\puzzles

P:\ denemeler \ gitdeneme1> git状态 在分支母版上未跟踪的文件:
(使用"git add ..."将要提交的内容包括在内)

P:\denemeler\gitdeneme1>git status On branch master Untracked files:
(use "git add ..." to include in what will be committed)

    linkDirectory/

未添加任何内容来提交但存在未跟踪的文件(使用"git add" 跟踪)

nothing added to commit but untracked files present (use "git add" to track)

P:\ denemeler \ gitdeneme1> git添加linkDirectory

P:\denemeler\gitdeneme1>git add linkDirectory

P:\ denemeler \ gitdeneme1> git状态

P:\denemeler\gitdeneme1>git status

在分支主服务器上更改为 已提交:(使用"git reset HEAD ..."取消登台)

On branch master Changes to be committed: (use "git reset HEAD ..." to unstage)

    new file:   linkDirectory/Juggle Fest Question.txt
    new file:   linkDirectory/jugglefest.txt
    new file:   linkDirectory/triangle.txt
    new file:   linkDirectory/triangleQuestion.txt

P:\ denemeler \ gitdeneme1> git commit -m新文件"

P:\denemeler\gitdeneme1>git commit -m "new files"

[master 0c7d126]新 文件已更改4个文件,14150插入(+)创建模式100644 linkDirectory/Juggle Fest Question.txt创建模式100644 linkDirectory/jugglefest.txt创建模式100644 linkDirectory/triangle.txt创建模式100644 linkDirectory/triangleQuestion.txt

[master 0c7d126] new files 4 files changed, 14150 insertions(+) create mode 100644 linkDirectory/Juggle Fest Question.txt create mode 100644 linkDirectory/jugglefest.txt create mode 100644 linkDirectory/triangle.txt create mode 100644 linkDirectory/triangleQuestion.txt

P:\ denemeler \ gitdeneme1>回显"aa"> p:\ puzzles \ newFile.txt

P:\denemeler\gitdeneme1>echo "aa" > p:\puzzles\newFile.txt

P:\ denemeler \ gitdeneme1> git状态

P:\denemeler\gitdeneme1>git status

在分支母版上未跟踪的文件:
(使用"git add ..."将要提交的内容包括在内)

On branch master Untracked files:
(use "git add ..." to include in what will be committed)

    linkDirectory/newFile.txt

未添加任何内容来提交但存在未跟踪的文件(使用"git add" 跟踪)

nothing added to commit but untracked files present (use "git add" to track)

这篇关于在Windows上使用Git将symlink文件添加为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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