top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

git grep seems to use the wrong .gitattributes when invoked in a subdirectory

0 votes
411 views

I bumped into a problem where git grep thinks files in repo/a/data are binary files when it is invoked from repo/a and repo/data/.gitattributes contains "* binary".

I can reproduce this on 1.7.9.5 and 1.7.10.4. Unfortunately I don't have a newer version at hand.

How to reproduce:

[pseudo:~/tmp]% git --version
git version 1.7.10.4
[pseudo:~/tmp]% git init git-test
Initialized empty Git repository in /home/opqdonut/tmp/git-test/.git/
[pseudo:~/tmp]% cd git-test
[pseudo:~/tmp/git-test:master()]% mkdir -p a/data
[pseudo:~/tmp/git-test:master()]% mkdir data
[pseudo:~/tmp/git-test:master()]% echo '* binary' > data/.gitattributes
[pseudo:~/tmp/git-test:master()]% echo foo > a/data/foo
[pseudo:~/tmp/git-test:master()]% git add -A
[pseudo:~/tmp/git-test:master()]% git commit -m "foo"
[master (root-commit) 20fafbb] foo
 2 files changed, 1 insertion(+)
 create mode 100644 a/data/foo
 create mode 100644 data/.gitattributes
[pseudo:~/tmp/git-test:master()]% git grep foo
a/data/foo:foo
[pseudo:~/tmp/git-test:master()]% cd a
[pseudo:~/tmp/git-test/a:master()]% git grep foo
Binary file data/foo matches
posted May 23, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Just checked, with git 1.8.2.3 the last command shows a matching line.

The issue has probably been fixed by 55c6168 (grep: stop looking at random places for .gitattributes). The lowest release with that patch is git 1.8.0.1.

answer May 23, 2013 by anonymous
Similar Questions
0 votes

I write here because since my ubuntu update (quantal to raring) and git update from 1.7.10.4-1ubuntu1 to 1.8.1.2

my export script doesn't work anymore.

I tried to put .gitattributes or .git/info/attributes, the file is the following http://pastebin.com/irngA1L8

the git is

git clone http://boinc.berkeley.edu/git/boinc-v2.git

and the command is

git archive --prefix boinc-7.1.7+dfsg/ --format tgz -o ../boinc_7.1.7+dfsg.orig.tar.gz -9 client_release/7.1/7.1.7

The archive gets created, but every file is inside, no exclusions at all.

I suspect a regression between git 1.7 and 1.8

0 votes

$ git push origin :ABRANCHNAME
remote: Firing Pre - receive hook
remote:
remote:
remote: Firing Post receive hook
remote:
remote: Branch is ABRANCHNAME -- not creating Trigger file since this is not _int branch
remote: error: Trying to write ref refs/tags/ABRANCHNAME!SN-BL-20130605_100513_04363 with nonexistent object 0000000000000000000000000000000000000000
remote: fatal: refs/tags/ABRANCHNAME!SN-BL-20130605_100513_04363: cannot update the ref
To ssh://git@ourgitserver/repositoryname.git
- [deleted] ABRANCHNAME

I would not expect this behavior. Is git attempting to modify the tags associated to the HEAD commit on the branch in addition to the branch? If so, I would like to consider this a bug report...

0 votes

I have a local repository and a remote at GitHub. My local repo had a master branch and the remote had only a gh-pages branch.

I wanted to pull from my gh-pages remote branch (with "git pull origin gh-pages"). I was about to commit on the master branch and I realized I had no local gh-pages branch. So I put a blank message, to avoid commiting to the master branch.

I unstaged the changes with "git reset HEAD", but how can I remove the already fetched files. I mean, is there something I have to do after unstaging the fetched files?

Many thanks for your help,

+5 votes

I know form the "git log" we can now the commit time, but how to know when it is in the remote git server.

+1 vote

I'm having difficulty understanding how I should use git when I have multiple independent changes in a project. I have a local git repository for various windows & linux machines and I work on different parts of the project on different machines. The situation I have is that I am part way through some changes on one part of the project. On the same machine, I have made some quick changes to another part of the project and I would like to commit those changes and push them to the origin, _without_ having to commit the other changes that I am still working on. Surprisingly, I don't seem to be able to do this with git.

  • I can commit the completed changes without committing the uncompleted changes ok.
  • If I try to push the changes, git complains that I have unstaged changes and I should do a local merge.
  • I can't even seem do a local merge without pulling other changes from the origin.

So now I've ended up with part-finished changes on the master. Not what I wanted! What should I be doing here?

...