Skip to main content

Intro

Git is divided into two different parts.

  • Porcelain: High-level commands that are user-friendly.
  • Some of the high-level commands are:
    • git add
    • git commit
    • git push
    • git pull
    • git fetch
    • git merge
    • git status
  • Plumbing: Low-level commands that are used to build the high-level commands.
  • Some of the low-level commands are:
    • git hash-object
    • git cat-file
    • git commit-tree
    • git update-ref
    • git checkout-index
    • git read-tree
    • git write-tree

99% of the time, you will be using the high-level commands.

Git Configuration

The git configuration will contian your information.

There are 2 config levels:

  • Global
  • Repo(Project)

Most of the time you will jujst use global config

Check Config

Check if user.name and user.email are set.

git config --get user.name
git config --get user.email

Set Config

If not set, Add your gitlab email and username

git config --add --global user.name "gitlab_username"
git config --add --global user.email "[email protected]"

command breakdown:

  • git config: The command to interact with the git configuration.
  • --get: The flag to get the value of the config.
  • --add: The flag to add a new config.
  • --global: The flag to set the global config.
  • user: The user section
  • name: The name of the user within the section
  • email: The email of the user within the section

Lets also set a default branch of master

git config --global init.defaultBranch master

Config File

You can also edit the config file directly and check your settings with the .gitconfig file. It is located in the home folder.

cat ~/.gitconfig
[user]
name = gitlab_username
email = [email protected]
[init]
defaultBranch = master

Key/Value Store

Only a few fields are used by the git system but it can be used as a key value store.

using local can add these values to the local projects config

git config --add --local project.name  "demo"
git config --add --local project.maintainer "brock"
git config --get project.name 
demo

remove a key

git config --unset project.name 

List all the config values

git config --list --local
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
project.name=demo
project.maintainer=brock