Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have a custom .gitignore? Read only access?

Tags:

git

gitignore

I am working in a team environment, and there is already a .gitignore file.

I want to add more items to the .gitignore file, but I don't want to check this file in either. It is possible to set custom ignore files which only apply to me?

Also, I want to give someone read only access to a private git repository on our server, if I add their SSH key to our server they will get full access like everyone else. How can I limit it to read-only, no commits allowed.

like image 739
Blankman Avatar asked May 24 '11 21:05

Blankman


People also ask

Can I have a personal Gitignore?

Yes! Edit the exclude file to get repo specific ignore of files or file patterns. Great for scripts that I want to use for that repo and store in that repo, but don't want committed to the project at large, and don't want cluttering the . gitignore file that is shared by everybody.

Does Gitignore have to be committed?

gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

Does Gitignore only work when committed?

Yes, unless that file was added before the . gitignore , or if it was force added.


2 Answers

  1. Put your private ignore rules in .git/info/exclude. See gitignore(5).
  2. For read-only access, use git-daemon, a web server, or Gitosis, or Gitolite.
like image 110
Fred Foo Avatar answered Sep 21 '22 21:09

Fred Foo


I know I am a little late to the conversation but you might want to consider using

git update-index --assume-unchanged [ FILE ] 

As the git help document states:

When the "assume unchanged" bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file...

Emphasis mine. It goes on to say

This option can be ... used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

So just keep in mind that you will have to be aware of any upstream changes made to these files.

In the event that you want to start tracking the file again all you have to do is use

git update-index --no-assume-unchange [ FILE ] 

I hope this helps any future viewers of this post.

like image 22
Jake Greene Avatar answered Sep 21 '22 21:09

Jake Greene