Git 和符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15304236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:17:52  来源:igfitidea点击:

Git and symlinks

git

提问by Marty Wallace

I have 2 issues:

我有两个问题:

  1. I want git to ignore symlinks
  2. I have noticed late that it is committing symlinks. HOw can i remove these committed symlinks. They have already been pushed to a remote.
  1. 我想让 git 忽略符号链接
  2. 我很晚才注意到它正在提交符号链接。我如何删除这些提交的符号链接。他们已经被推到了远程。

回答by Alec

add all symbolic links in .gitignore

添加所有符号链接 .gitignore

find . -type l >> .gitignore

remove all symbolic links from repository

从存储库中删除所有符号链接

find . -type l -exec git rm --cached {} \;

回答by twalberg

1) Don't git addany symlinks then. That includes things like git add -Aand what-not that automatically add things that aren't currently being tracked.

1)git add然后不要任何符号链接。这包括git add -A自动添加当前未跟踪的内容之类的内容。

2) git rm <symlink>; repeat for each symlink, then git commit. Of course you'll need to do this on every branch. Also, if you want to remove all symlinks throughout your project's history, you'll need to do the same on every commit, which can be done with git filter-branch.

2) git rm <symlink>; 对每个符号链接重复,然后git commit. 当然,您需要在每个分支上执行此操作。此外,如果您想删除整个项目历史中的所有符号链接,则需要在每次提交时执行相同的操作,这可以使用git filter-branch.