Git Tips
Maintaining a Shared Bare Repository
If the repository is shared by multiple users using git-push to update it, you will need to do something to ensure all users have write access to the repository's files and directories. Create a group and add all users to that group. Set the group suid bit on all directories in the repository so that any new files and directories will be created with the same group as the parent directory. Set the core.sharedRepository config option to group, so that git-push maintains files as group writable.
$ cd /myrepository
$ git-config --add core.sharedRepository group
$ chgrp -R our_group .
$ chmod -R g+w .
$ find . -type d -exec chmod g+ws '{}' ';'
Tagging
$ git tag -a <TAG> [<sha1>]
To push tags to a remote repository, include the '--tags' argument:
& git push --tags
Moving a Local Git Repository
You can copy or move a local Git repository with ordinary Unix commands like 'mv' and 'cp -a'. Afterwards, you need to update the indexes with:
$ git-update-index --refresh
See Copying Repositories in gitcore-tutorial(7).
Cleaning Working Branch
The following command will list un-tracked files:
$ git-ls-files -o
You can use git-clean to remove untracked files and directories. The following command will remove all untracked files and directories including files which are ignored (remove the --dry-run flag to actually delete the files and directories):
$ git-clean --dry-run -d -x
PS1 Prompt Showing Branch
Execute the following in your shell:
$ export PS1='$(__git_ps1 " (%s) ")'
or include the host and working directory:
$ export PS1='\u@\h:\w\$ $(__git_ps1 "(%s) ")'
FAT32
If you get an error message along the lines of fatal: Not a git repository it may have been caused by copying the files to a USB stick or similar using a FAT32 file system. HEAD then appears as head.
You'll need to copy it back to another partition type and rename head.
It's also a good idea to set the following properties:
$ git config --add core.filemode false
$ git config --add core.symlinks false
$ git config --add core.ignorecase true
Reference Documentation
- Git Quick Reference
- git(1]
- Git User's Manual
- gittutorial(7)
- gittutorial-2(7)
- gitcore-tutorial(7)
- Everyday Git
- git-svn(1)
References
-- Frank Dean - 22 Oct 2009