gitattributes

Whitespace in .gitattributes patterns

回眸只為那壹抹淺笑 提交于 2019-12-22 04:59:53
问题 I am writing some tools for git that make use of smudge/clean filters, and so I must create entries in the .gitattributes file. Unfortunately, that file is parsed rather simply by splitting on whitespace, and so it is does not seem possible to me to include an explicit space character in the pattern. I have been replacing whitespace characters with ? , which matches again zero or one characters. Ergo, a pattern of has?spaces will match against my target filename of has spaces , but also

Apply multiple filters for same files in git

不打扰是莪最后的温柔 提交于 2019-12-21 17:37:38
问题 I am using Git for version control of local files, which finally have to be checked in into another version control system. Now I am experiencing some problems with most of the C code files: They all have an automatic version history in their header comment Most of the files are cluttered by EasyCode or EasyCase comments I now simply created two git filters "History" and "EasyTool" to clean up the code before being checked in to Git. How is it possible to filter all C and H files with both of

What is wrong with this git smudge/clean filter?

笑着哭i 提交于 2019-12-20 10:48:16
问题 I want to apply this filter in my git repository to remove a section from a solution file during checkout and to add this section during commit. This is the section i want to remove or add: GlobalSection(SubversionScc) = preSolution Svn-Managed = True Manager = AnkhSVN - Subversion Support for Visual Studio EndGlobalSection I have setup this filter in my .git/info/attributes *.sln filter=SourceControlProvider and i have added these commands to my config $ git config filter

Git messed up my files, showing chinese characters in some places

别等时光非礼了梦想. 提交于 2019-12-20 09:31:21
问题 disclaimer: By Git, I mean 'I' messed up. Earlier, I wanted git-gui to show me the diff for which it thinks are binary files. So I made some changes to my .\.gitattributes *.ini text *.inc text But it didn't work. Then I made some changes to my .\.git\info\attributes *.ini text *.inc text *.inc crlf diff *.ini crlf diff and it worked. But now when I go back to previous commits it messes up... This is how it should look: It doesn't happen in all the files. EDIT: It happens only in files that

merge strategy in .gitattributes not working

妖精的绣舞 提交于 2019-12-19 11:03:24
问题 I want git to never have a conflict on this file: test/file.txt when merging. I tried the following in .gitattributes test/file.txt merge=theirs but I need to define the theirs merge strategy. I saw online that I can define the ours strategy by executing this: git config --global merge.theirs.driver true which sets the driver to true (bash true) which will keep the local file instead of the new one. I want to do the opposite. How can I define the theirs driver to get the new copy and discard

How to list all distinct extensions of tracked files in a git repository?

≯℡__Kan透↙ 提交于 2019-12-19 09:07:10
问题 I'd like to know all distinct extensions of files tracked by git in a given repo, in order to create appropriate .gitattributes file. Example output expected: bat gitignore gradle html jar java js json md png properties py svg webp xml yml What command can I use for that? 回答1: git ls-tree -r HEAD --name-only | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u When you declare it as an alias, you have to escape $1 : alias gitFileExtensions="git ls-tree -r HEAD --name-only | perl -ne 'print \$1

Why does 'git status' ignore the .gitattributes clean filter?

不想你离开。 提交于 2019-12-18 12:28:10
问题 I have a .gitattributes clean filter to remove all comments from a file before committing. $ cat .git/config [filter "cleancomments"] clean = "grep -v '^#'" $ cat .gitattributes * filter=cleancomments And I have a file 'test' with following content (committed in the repository): This is a file with random content Now I make a modification to 'test' and add comments: This is a file with random content # and some comments # like this git status now tells me: modified: test but git diff is empty

What is the purpose of `text=auto` in `.gitattributes` file?

。_饼干妹妹 提交于 2019-12-18 10:02:21
问题 Mostly .gitattributes file has * text=auto . What is the purpose of text=auto in that file? 回答1: From the docs: Each line in .gitattributes (or .git/info/attributes ) file is of form: pattern attr1 attr2 ... So here, the pattern is * , which means all files, and the attribute is text=auto . What does text=auto do? From the documentation: When text is set to "auto", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are

What is the purpose of `text=auto` in `.gitattributes` file?

早过忘川 提交于 2019-12-18 10:02:14
问题 Mostly .gitattributes file has * text=auto . What is the purpose of text=auto in that file? 回答1: From the docs: Each line in .gitattributes (or .git/info/attributes ) file is of form: pattern attr1 attr2 ... So here, the pattern is * , which means all files, and the attribute is text=auto . What does text=auto do? From the documentation: When text is set to "auto", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are

How to create a Git attributes file

我只是一个虾纸丫 提交于 2019-12-17 22:46:53
问题 I would like to add an attributes file to my Git repository as described here. It indicates that I should include .gitattributes in the root folder of my repository. Is .gitattributes simply a file or is it a folder ? How do I create this file/folder ? Windows raises the following errors : "Can't create a file without a filename" "You must type a filename" Where should one add the file ? Under the repository root, X:\PATH\TO\Repository\ , or the Git folder, X:\PATH\TO\Repository\.git\ ? Will