Lossless·Toolkit

Git

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

Git — site preview

Git Hooks

Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git’s internal behavior and trigger customizable actions at key points in the development life cycle. Atlassian on Git Hooks.

[Image Description]

  • One widely cited graphic (not included here) shows Git’s adoption at almost 94%, with a small sliver for SVN and other tools—demonstrating its dominance in developer surveys53.
  • Another illustrative chart (not shown) tracks adoption growth: Git rises from 69.3% (2015) to 88.4% (2018), while alternatives decline3.

Git Branch

Branch Naming Strategies

Branch names can be anything you’d like. However, your organization or project may have standards outlined for branch naming. For example, naming the branch based on the person responsible for working on the branch and a description or work item:

  • username/description
  • username/workitem

You can name a branch to indicate the branch’s function, like a feature, bug fix, or hotfix:

  • bugfix/description
  • feature/feature-name
  • hotfix/description

Another branching strategy is having branches dedicated to the different development cycles, like feature or hotfix. As work items come up, you create a branch for that item from its respective branch. Yes, you can create branches from branches! Check out Option 4 below for an example. [^1]

Git Merge

The recommended process is:

  1. Switch to main (yes, you'll briefly see the old code)
  2. Immediately merge development-temp into main (which will bring all your new changes into main)
  3. After the merge, main will have all your latest work

This is the standard and safest way to merge branches. Your development-temp branch will still exist afterward, so you can't lose anything. If something goes wrong (which is unlikely), you can always switch back to development-temp where all your work is safe.

``bash git checkout main git diff site/src/content/tooling/Software\ Development/Databases/Postgres.md git merge development-temp --strategy-option theirs git add site/src/content/tooling/Software\ Development/Databases/Postgres.md git commit -m "Merge development-temp branch, keeping development-temp version of Postgres.md" git status git log --oneline -n 3 git log -n 1 git merge development-temp ``

git diff site/src/content/tooling/Software\ Development/Databases/Postgres.md

[^1]: Git Branching and Merging: A Step-By-Step Guide