docs

a slatepencil documentail site

View on GitHub

git commands

.git
├── branches
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── fsmonitor-watchman.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── pre-merge-commit.sample
│   ├── prepare-commit-msg.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   ├── pre-receive.sample
│   └── update.sample
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs
├── heads
└── tags

Ubuntu install

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Git practices

echo 'test text' | git hash-object -w --stdin

git cat-file -t .git/objects/d6/..hash
git cat-file -p .git/objects/d6/..hash

find .git/objects -f

echo 'test text' > test.txt
git hash-object -w test.txt
git update-index --add --cacheinfo 100644 d6..hash
git write-tree

git ls-files -s
# Rebase current HEAD point and back one commit onto the origin/master branch
git rebase --onto origin/master HEAD~ HEAD

# Rebase current HEAD point and back 8 commits onto the origin/master branch
git rebase --onto origin/master HEAD~8 HEAD

# Rebase current branch "branch-name" and back 5 commits onto the origin/master branch
git rebase --onto origin/master branch-name~8 branch-name

# Push your change to the remote branch develop at the origin server
git push origin HEAD:develop
# These commands push a given <BranchToPush> to the remote master or remote develop branch
git push origin <BranchToPush>:develop
git push origin <BranchToPush>:master

# Show-Ref Commands, used to see all recent changes
git show-ref master
git show-ref HEAD
git show-ref branch

CheatSheet

Submodule

# main repo
git remote add origin git@github.com:cu-ecen-aeld/assignment-1-username.git
git pull
# add submodule
git submodule add https://gitlab.com/buildroot.org/buildroot/
# or
git remote add assignments-base https://github.com/cu-ecen-aeld/aesd-assignments.git
#  pulls the content locally to match the latest status at https://github.com/cu-ecen-aeld/aesd-assignments
git fetch assignments-base
# This command makes your master branch match the master branch
git merge assignments-base/master
# clones the `assignment-autotest` submodule and nested git repositories
git submodule update --init --recursive

# To clone a project with submodules
git clone --recurse-submodules git@github.com:cu-ecen-aeld/assignment-1-username.git

Github self-host runner

# Create a folder
$ mkdir actions-runner && cd actions-runner
Copied!# Download the latest runner package
$ curl -o actions-runner-linux-x64-2.322.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.322.0/actions-runner-linux-x64-2.322.0.tar.gz
Copied! # Optional: Validate the hash
$ echo "b13b784808359f31bc79b08a191f5f83757852957dd8fe3dbfcc38202ccf5768  actions-runner-linux-x64-2.322.0.tar.gz" | shasum -a 256 -c
# Extract the installer
$ tar xzf ./actions-runner-linux-x64-2.322.0.tar.gz

# Configure
# Create the runner and start the configuration experience
$ ./config.sh --url https://github.com/cu-ecen-aeld/assignment-1-username --token token_provided_by_github
# Last step, run it!
$ ./run.sh

.github/workflows/github-actions.yml

name: assignment-test
on:
  push:
    tags-ignore:
      - "*"
    branches:
      - "*"
jobs:
  unit-test:
    container: cuaesd/aesd-autotest:24-unit-test
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Checkout submodules
        run: git submodule update --init --recursive
      - name: Run unit test
        run: ./unit-test.sh
  full-test:
    container: cuaesd/aesd-autotest:24-assignment1
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Checkout submodules
        run: git submodule update --init --recursive
      - name: Run full test
        run: ./full-test.sh

ssh

ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519

Git Internals - Evnironment Variables

# verbose logging
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull

## ssh debug
GIT_SSH_COMMAND="ssh -vvv" git --no-replace-objects ls-remote ssh://git@git.github.com/npm/ipqs_iam.git

Proxy config

# view
git config --glbal -l
# set proxy
git config --global http.proxy 127.0.0.1:59527
git config --global https.proxy 127.0.0.1:59527

npm config set proxy http://127.0.0.1:59527
npm config set https-proxy http://127.0.0.1:59527

# unset
git config --global --unset http.proxy
git config --global --unset https.proxy

windows git issue

# windows: \r\n  unix: \r   linux: \n
git config --global core.authocrlf true

# file perimission auto change
git config --add core.filemode false
git status | grep typechange | awk '{print $2}' | xargs git checkout

## soft link
# 1. find ln files 120000
git ls-files -s
# 2. edit ln files with `mklink`
mklink [/D] [/H] [/J] LINK TARGET
# 3. block ln files modification
git update-index --assume-unchanged