Skip to content

Latest commit

 

History

History
110 lines (72 loc) · 2.58 KB

presentation.md

File metadata and controls

110 lines (72 loc) · 2.58 KB

Git configuration

  • To setup git properly use git config

  • You can always edit the ~/.gitconfig file for global configuration

  • Edit the .git/config file for a per repository configuration

  • Use the --global for setting up global configuration

  • Use the --local for setting up local configuration

  • To initialize a git repository

git init

Git config options

  • Every command we use can change either the local or the global configuration depending on the flag

  • To view the current global configuration:

git config --global --list
  • To view the current local configuration
git config --local --list

Set configuration

  • To set configuration
git config --global --set alias.l1 "log --oneline -n 10"
  • With this set we can run git l1 as if we were running git log --oneline -n 10

  • You can add this either in the ~/.gitconfig or in the ./.git/config files depending if you want to do it globally or not

Pagination

  • Git uses under the hood less to show its results, that makes that it paginates them, however you can disable

  • Per command, always goes between the git and the command

git --no-pager log
  • You can disable it by changing its default pager
git config --global --set core.pager cat

Adding chunks to the staging area

git add -p

Rephrasing your commit

  • To rephrase your last commit
git commit --amend
  • WARNING Do not amend your commit once pushed

Adding info to the commit

git commit --trailer "Signed-off-by:C O Mitter \ <[email protected]>" --trailer "Helped-by:C O Mitter \ <[email protected]>"

Adding a commit without any files

git commit --allow-empty -m "Initial commit"

Git Worktrees

You can clone a remote repository into a Git Worktree configuration by running

git clone --bare https://github.com/chingu-voyages/roundtable-advanced-git.git

That will display all the git files that you usually see inside of the .git directory, to add those to a hidden file we will need to execute:

git clone --bare https://github.com/chingu-voyages/roundtable-advanced-git.git .bare
echo "gitdir: ./.bare" > .git

This will clone the repo into the .bare directory and tell git that its configuration files are located inside the .bare directory

Resources