gitattributes

Is it possible to have all “git diff” commands use the “Python diff”, in all git projects?

一笑奈何 提交于 2019-12-03 05:29:50
When including the line *.py diff=python in a local .gitattributes file, git diff produces nice labels for the different diff hunks of Python files (with the name of the function where the changes are, etc.). Is is possible to ask git to use this diff mode for all Python files across all git projects? I tried to set a global ~/.gitattributes, but it is not used by local git repositories. Is there a more convenient method than initializing each new git project with a ln -s ~/.gitattributes ? Quoting from gitattributes(5) : Attributes that should affect all repositories for a single user should

What is wrong with this git smudge/clean filter?

China☆狼群 提交于 2019-12-03 00:24:51
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.SourceControlProvider.smudge "sed -e '/GlobalSection(SubversionScc)/,/EndGlobalSection/d' %" $ git config filter

Is it possible to make .gitignore changed according to environment variables

混江龙づ霸主 提交于 2019-12-02 18:03:22
问题 Is it possible to add to .gitignore rules depends on environment variables? for example if -e $(ENV_VAR) "AAA" !liba.so else liba.so Basically what I want is to have a repository such that if ENV_VAR = "AAA" the local repository will have a.txt and if ENV_VAR isn't set the a.txt will be removed. 回答1: The answer is no. Gitignore rules are completely static. Further that would not even make any sense. Once a file is in the repo, gitignore does not apply to it anymore – it only prevents new

How can I merge in Git without changing config files in master?

蹲街弑〆低调 提交于 2019-12-02 02:22:07
We have a number of configuration files that contain information, such as a url, that need to be modified for our developer environment. We create the developer environment as a branch in git, and make the changes to the configuration files. The problem is that when we merge the development branch back to the master branch, it changes the configuration files in the master branch. We would like to store the files in git, so I do not believe we can use .gitignore. We need to keep all of our source in the repo since we are using elastic beanstalk, and need to deploy the entire source each time.

merge strategy in .gitattributes not working

白昼怎懂夜的黑 提交于 2019-12-01 11:54:10
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 the local one when merging (after a git pull)? VonC How can I define the theirs driver to get the new

How to setup gitattributes to filter part of a file?

左心房为你撑大大i 提交于 2019-12-01 11:37:27
I am using Visual Studio 2010 and git (git svn). My coworker uses pure svn with the Ankhsvn plugin. When i try to open the file with the Git Source Control Provider enabled, Visual Studion complains: Source Control Plug-in The active solution or project is controlled by adifferen source control plug-in than the one you have selected. If you change the source control plu-in, the active solution or project will be closed. Do you want to continue? When i click yes an empty solution is opened. When i click no, all the git specific icons next to the solution items are missing (i still see the

How to setup gitattributes to filter part of a file?

白昼怎懂夜的黑 提交于 2019-12-01 09:43:58
问题 I am using Visual Studio 2010 and git (git svn). My coworker uses pure svn with the Ankhsvn plugin. When i try to open the file with the Git Source Control Provider enabled, Visual Studion complains: Source Control Plug-in The active solution or project is controlled by adifferen source control plug-in than the one you have selected. If you change the source control plu-in, the active solution or project will be closed. Do you want to continue? When i click yes an empty solution is opened.

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

天涯浪子 提交于 2019-12-01 06:59:39
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? jakub.g 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 if m/\.([^.\/]+)$/' | sort -u" This is better than naive find , because: it excludes untracked

Fixing the line-endings in a Git repository using the `.gitattributes` file

我的未来我决定 提交于 2019-12-01 05:29:08
问题 What needs fixing: I have a repository containing a single .md file, which contains an essay I am writing. I edit the file from a few different computers, one running Linux and a couple running Windows. Looking at a git diff in Windows now where I have made some changes, I can see my essay showing as nicely separated lines of text ... all about to be removed and replaced by one long line where what were paragraphs are separated by ^M s. I'm aware that ^M refers to Windows' CLRF line endings.

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

风流意气都作罢 提交于 2019-11-30 09:00:19
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 (as it should). It is not completely clear to me why git status does not use the filter to decide if a