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.
.git/info/exclude
. Seegitignore(5)
.git-daemon
, a web server, or Gitosis, or Gitolite.You may be interested in an update hook that Junio wrote and that Carl improved. Place the code below in
$GIT_DIR/hooks/update
and don't forget to enable it withchmod +x
.With this hook in place, you then give particular users or groups to make changes to the repository. Anyone else who can see it has read-only access.
If this person doesn't already have access to the host where your repository lives, maybe that person should have only
git-shell
access rather than unrestricted access. Create a special-purpose git user and in~git/.ssh/authorized_keys
, add the outsider's SSH key in the following form. Note that the key should be on one long line, but I've wrapped it below to aid presentation.Depending on your local setup, you may need to adjust the path to
git-shell
. Remember thatsshd
is highly paranoid about permissions of the.ssh
directory, so turn off its group-write bits and all files beneath it.Funneling everyone through the git user means you need to be able tell people apart, and this is the purpose of the
myorg_git_user
environment variable. Instead of relying on an unconditionalusername=$(id -u -n)
, tweak your update hook to use it:With this setup, your friend with readonly access will clone with a command resembling the one below. The particular path will depend on your setup. To make the nice path work, either relocate your repository to the git user's home directory or create a symlink that points to it.
but won't be able to make updates.
You said you're working in a team environment, so I assume your central repository was created with the
--shared
option. (Seecore.sharedRepository
in thegit config
documentation and--shared
in thegit init
documentation.) Make sure the new git user is a member of the system group that gives all of you access to your central repository.Like Fred Frodo said, you can put your private exclude rules in the
.git/info/exclude
of the repository.If you want to apply the same exclude rules to all the repositories on your machine, you can add the following to the
.gitconfig
file in your user directory.Then add your exclude patterns to
~/.gitexclude
.I know I am a little late to the conversation but you might want to consider using
As the git help document states:
Emphasis mine. It goes on to say
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
I hope this helps any future viewers of this post.
For the ssh part, you should consider using Gitolite (a replacement for gitosis).