Git

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Installation

brew install git

Configuration

With --global option, git config add configurations into ~/.gitconfig. Otherwise, configurations get added into the .git/config file which locate in the main directory of your project.

git config --global user.name "your_name"
git config --global user.email "[email protected]"
# Use osxkeychain as your credential storage enable you to use HTTP protocols without a passphrase:
git config --global credential.helper osxkeychain
# (Optional) Add accessory credential storage -- plain-text credentials file on your portable driver
git config --global credential.helper "store --file <path-to-your-portable-driver>/.git-credentials"
# Enable GPG sign on all comments and specify the default GPG key-id:
git config --global commit.gpgsign true
git config --global user.signingkey <gpg-key-id>
# Output the paths containing bytes higher than 0x80 verbatim:
git config --global core.quotepath false

Note: git tag -s <version> -m <description> -u <key-id> sign your tag on your release with a specific PGP(Pretty Good Privacy) key. The default parameter of -u(--local-user) which specify the <key-id> is'your_name <[email protected]>' which import from your git config file. You'd ensure the pub/secret keypair of this <key-id> is generated by gpg --gen-key command first. Get the gpg info on Credential section.

Learning about git

Learning in CLI

  1. git help -a lists all available subcommands;
  2. git help -g lists some concept guides:

    | Guide | Description | :-------- | :---------- | attributes| Defining attributes per path | everyday | Everyday Git With 20 Commands Or So | glossary | A Git glossary | ignore | Specifies intentionally untracked files to ignore | modules | Defining submodule properties | revisions | Specifying revisions and ranges for Git | tutorial | A tutorial introduction to Git (for version 1.5.1 or newer) | workflows | An overview of recommended workflows with Git

See git help <command> or git help <concept> to read about a specific subcommand or concept.

Untracking files

To tell git which files to be ignored to being tracked, make use of .gitignore files. Git ignores files according to the file .gitignore which locates in your repository and global excludes attribute. If this file is related with project tightly, add it to your commit for sharing the settings with others.

A universal .gitignore file sample:

# OS generated files
._*
.DS_Store
.Spotlight-V100
.VolumeIcon.icns
.TemporaryItems
ehthumbs.db
Thumbs.db
desktip.ini

# Backup files and temporary files
*~
*#
.#*
*.bak
*.backup

# Logs and databases
*.log
*.sql
*.sqlite

# For special applications
.idea
node_modules
.sass-cache

Put such a .gitignore file in $HOME directory and make it take effect by running git cinfig command for daily using:

git config --global core.excludesfile ~/.gitignore

https://github.com/github/gitignore provides many .gitignore templates.

You cloud pick up templates which are best for your habits(filter files generated by editors, IDEs, applications and so on) and config it globally or add their contents into your project's .gitignore.

results matching ""

    No results matching ""