Skip to content

Latest commit

 

History

History
103 lines (86 loc) · 2.46 KB

cix-git.org

File metadata and controls

103 lines (86 loc) · 2.46 KB

git

|≣|

AuthorLinus Torvalds
Maintainer(s)
Released2005
Sourcegit.git
Homepagegit.web

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.


Index

Receipts

git

git::examples

git-170828222035

list top 10 contributers to the project:

   ~$ git log --format='%aN' | sort | uniq -c | sort -rn | head

git-180628235119

list top 10 version tags:

   ~$ git tag | sort -Vr | head

git-180808223805

list files are being tracked on master branch:

   ~$ git ls-tree -r master --name-only

git-180808223944

list files that ever existed including deleted files:

   ~$ git log --pretty=format: --name-only --diff-filter=A | sort - | sed '/^$/d'

git-180808234518

completely remove tracked files from git history:

#!/usr/bin/env bash

# Wild card, regex list of files to be removed from git tracking
RM_LST=(
    "cache"
    "host_vars/.*yml"
    "generated/.*yml"
)

get_rm_lst()
{
    local rm_file="$1"

    git log \
        --pretty=format: \
        --name-only \
        --diff-filter=A \
        | grep "${rm_file}"
}

flush_git()
{
    local rm_file="$1"

    git filter-branch \
        --force \
        --index-filter \
        "git rm --cached --ignore-unmatch ${rm_file}" \
        --prune-empty \
        --tag-name-filter \
        cat -- \
        --all
}

main()
{
    for ff in ${RM_LST[@]}; do
        for f in $(get_rm_lst ${ff}); do
            echo "$f"
            flush_git $f
        done
    done
}

main "$@"
# End of script

git-200702111041

restore accidentally changed files to latest commit:

   ~$ git status | awk '/modified/{print $2}' | xargs -I{} git restore {}

aws xargs

References