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
Git and symlinks
提问by Marty Wallace
I have 2 issues:
我有两个问题:
- I want git to ignore symlinks
- I have noticed late that it is committing symlinks. HOw can i remove these committed symlinks. They have already been pushed to a remote.
- 我想让 git 忽略符号链接
- 我很晚才注意到它正在提交符号链接。我如何删除这些提交的符号链接。他们已经被推到了远程。
回答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 add
any symlinks then. That includes things like git add -A
and 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
.