Git Configuration19 Jul 2015 • Leave Comments
# emerge -av dev-vcs/git
If you'd like a per-user config, create this file first.
In Gentoo Xfce4,
$XDG_CONFIG_HOMEis not set by default. Without touching this file manually, it would defaults to
git config --system user.name "<username>"
Specify a name so your commits will be properly labeled. It can be anything that is meaningful to you.
git config --system user.email "<id+username>@users.noreply.github.com"
Tell Git the email address that will be associated with your Git commits. The email you specify should be the same one found in your email settings. To keep your email address hidden, see Keeping your email address private.
git config --system core.editor emc
You can configure the default text editor that will be used when Git needs you to type in a message (without
-mopton on push). If not configured, Git uses your system’s default editor, which is generally one of Vim, Emacs and Nano.
git config --system credential.helper 'cache --timeout=3600'
If you're managing GitHub repositories using HTTPS due to SSH blocked by company firewall, you can use a credential helper to tell Git to remember your GitHub username, password or API token for a while every time it talks to GitHub. By default, Git will cache your password for 15 minutes (900 seconds).
git config --system push.default simple
- For EOL conversion, refer to git line ending conversion.
git config --system -l
Check current config.
- For a single user system, you'd best use –system instead of –global.
For language-specific ignorance, refer to A collection of useful .gitignore templates.
Two consective stars followed by a slash (
**/) means to match all directories. Without the trailing slash, to match anything regardless of files or directories.
# ignore name 'foo' **/foo # equivalent to: foo # ignore name 'bar' under directory 'foo' **/foo/bar # ignore anything under directory 'foo' foo/**
- All patterns are relative to the location of the .gitignore file unless a leading slash is provided.
- Without trailing slash, a name can match a file or a directory.
Ignore a directory but a file.
The consecutive stars
**is to improve performance. Another way to solve this issue is creating a new .gitignore under my-dir:
# my-dir/.gitignore * !.gitignore !my-file
The newly created .gitignore has higher priority over those in uppper directories.
This is the global ignore list that applys to all Git repositories for current user.
For example, on my Gentoo:
*~ .#* \#*\#
The first line ignores Linux file auto-backup. The next two lines are for Emacs eidtor's backup.
If a file or directory is accidently pushed to remote repository, you decide to remove that later on.
Firstly, create a .gitignore file. Put patterns there to ignore unwanted names.
~ $ git rm -r --cached name; git commit -m "remove name"; git push