Skip to content

Instantly share code, notes, and snippets.

@bewuethr
Last active November 11, 2023 18:13
Show Gist options
  • Select an option

  • Save bewuethr/4d044f84989cb430a8b9c46dc4ea75c9 to your computer and use it in GitHub Desktop.

Select an option

Save bewuethr/4d044f84989cb430a8b9c46dc4ea75c9 to your computer and use it in GitHub Desktop.

Revisions

  1. bewuethr revised this gist Nov 11, 2023. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ git clone --bare "[email protected]:bewuethr/$repo" ".$repo"

    # Set local repo configuration
    git -C ".$repo" config user.name 'Benjamin Wuethrich'
    git -C ".$repo" config user.email [email protected].com
    git -C ".$repo" config user.email 'benjamin.wuethrich@gmail.com'
    git -C ".$repo" config status.showUntrackedFiles no
    git -C ".$repo" config core.sparseCheckout true
    cat <<- EOF > ".$repo/info/sparse-checkout"
    @@ -29,10 +29,10 @@ cat <<- EOF > ".$repo/info/sparse-checkout"
    EOF

    # Check out files - this overwrites existing files
    git --git-dir=".$repo" --work-tree=. checkout --force "${branch:-master}"
    git --git-dir=".$repo" --work-tree=. checkout --force "${branch:-main}"

    # Initialize submodules
    git --git-dir=".$repo" --work-tree=. submodule update --init

    # Set upstream
    git --git-dir=".$repo" --work-tree=. push --set-upstream origin "${branch:-master}"
    git --git-dir=".$repo" --work-tree=. push --set-upstream origin "${branch:-main}"
  2. bewuethr revised this gist Nov 9, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ cat <<- EOF > ".$repo/info/sparse-checkout"
    /*
    !README.md
    !LICENSE
    !.github/dependabot.yml
    EOF

    # Check out files - this overwrites existing files
  3. bewuethr revised this gist Sep 3, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -32,3 +32,6 @@ git --git-dir=".$repo" --work-tree=. checkout --force "${branch:-master}"

    # Initialize submodules
    git --git-dir=".$repo" --work-tree=. submodule update --init

    # Set upstream
    git --git-dir=".$repo" --work-tree=. push --set-upstream origin "${branch:-master}"
  4. bewuethr revised this gist Sep 3, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ cat <<- EOF > ".$repo/info/sparse-checkout"
    EOF

    # Check out files - this overwrites existing files
    git --git-dir=".$repo" --work-tree=. checkout -f "${branch:-master}"
    git --git-dir=".$repo" --work-tree=. checkout --force "${branch:-master}"

    # Initialize submodules
    git --git-dir=".$repo" --work-tree=. submodule update --init
    git --git-dir=".$repo" --work-tree=. submodule update --init
  5. bewuethr revised this gist Aug 17, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dfinit
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ git clone --bare "[email protected]:bewuethr/$repo" ".$repo"

    # Set local repo configuration
    git -C ".$repo" config user.name 'Benjamin Wuethrich'
    git -C ".$repo" config user.email [email protected]
    git -C ".$repo" config user.email 8521043+[email protected]
    git -C ".$repo" config status.showUntrackedFiles no
    git -C ".$repo" config core.sparseCheckout true
    cat <<- EOF > ".$repo/info/sparse-checkout"
  6. bewuethr revised this gist Aug 16, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,10 @@ fi
    git clone --bare "[email protected]:bewuethr/$repo" ".$repo"

    # Set local repo configuration
    git -C "$localdir" config user.name 'Benjamin Wuethrich'
    git -C "$localdir" config user.email [email protected]
    git -C "$localdir" config status.showUntrackedFiles no
    git -C "$localdir" config core.sparseCheckout true
    git -C ".$repo" config user.name 'Benjamin Wuethrich'
    git -C ".$repo" config user.email [email protected]
    git -C ".$repo" config status.showUntrackedFiles no
    git -C ".$repo" config core.sparseCheckout true
    cat <<- EOF > ".$repo/info/sparse-checkout"
    /*
    !README.md
  7. bewuethr revised this gist Aug 16, 2019. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -9,28 +9,26 @@ done

    if [[ -n $branch ]]; then
    repo='dotfiles-local.git'
    localdir='.dotfiles_local.git'
    else
    repo='dotfiles.git'
    localdir='.dotfiles.git'
    fi

    # Clone repository as bare repository
    git clone --bare "[email protected]:bewuethr/$repo" "$localdir"
    git clone --bare "[email protected]:bewuethr/$repo" ".$repo"

    # Set local repo configuration
    git -C "$localdir" config user.name bewuethr
    git -C "$localdir" config user.name 'Benjamin Wuethrich'
    git -C "$localdir" config user.email [email protected]
    git -C "$localdir" config status.showUntrackedFiles no
    git -C "$localdir" config core.sparseCheckout true
    cat <<- EOF > "$localdir/info/sparse-checkout"
    cat <<- EOF > ".$repo/info/sparse-checkout"
    /*
    !README.md
    !LICENSE
    EOF

    # Check out files - this overwrites existing files
    git --git-dir="$localdir" --work-tree=. checkout -f "${branch:-master}"
    git --git-dir=".$repo" --work-tree=. checkout -f "${branch:-master}"

    # Initialize submodules
    git --git-dir="$localdir" --work-tree=. submodule update --init
    git --git-dir=".$repo" --work-tree=. submodule update --init
  8. bewuethr revised this gist Aug 16, 2019. 1 changed file with 0 additions and 0 deletions.
    Empty file modified dfinit
    100644 → 100755
    Empty file.
  9. bewuethr revised this gist Aug 16, 2019. 1 changed file with 23 additions and 8 deletions.
    31 changes: 23 additions & 8 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,36 @@
    #!/usr/bin/env bash

    while getopts 'l:' opt; do
    case $opt in
    l) branch=$OPTARG ;;
    *) exit 1 ;;
    esac
    done

    if [[ -n $branch ]]; then
    repo='dotfiles-local.git'
    localdir='.dotfiles_local.git'
    else
    repo='dotfiles.git'
    localdir='.dotfiles.git'
    fi

    # Clone repository as bare repository
    git clone --bare [email protected]:bewuethr/dotfiles.git .dotfiles.git
    git clone --bare "[email protected]:bewuethr/$repo" "$localdir"

    # Set local repo configuration
    git -C .dotfiles.git config user.name bewuethr
    git -C .dotfiles.git config user.email [email protected]
    git -C .dotfiles.git config status.showUntrackedFiles no
    git -C .dotfiles.git config core.sparseCheckout true
    cat <<-EOF > .dotfiles.git/info/sparse-checkout
    git -C "$localdir" config user.name bewuethr
    git -C "$localdir" config user.email [email protected]
    git -C "$localdir" config status.showUntrackedFiles no
    git -C "$localdir" config core.sparseCheckout true
    cat <<- EOF > "$localdir/info/sparse-checkout"
    /*
    !README.md
    !LICENSE
    EOF

    # Check out files - this overwrites existing files
    git --git-dir=.dotfiles.git --work-tree=. checkout -f
    git --git-dir="$localdir" --work-tree=. checkout -f "${branch:-master}"

    # Initialize submodules
    git --git-dir=.dotfiles.git --work-tree=. submodule update --init
    git --git-dir="$localdir" --work-tree=. submodule update --init
  10. bewuethr revised this gist Aug 16, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dfinit
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,4 @@ EOF
    git --git-dir=.dotfiles.git --work-tree=. checkout -f

    # Initialize submodules
    git --git-dir=.dotfiles.git --work-tree=. submodule update --init --recursive
    git --git-dir=.dotfiles.git --work-tree=. submodule update --init
  11. bewuethr revised this gist Aug 12, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ cat <<-EOF > .dotfiles.git/info/sparse-checkout
    EOF

    # Check out files - this overwrites existing files
    git --git-dir=.dotfiles.git checkout -f
    git --git-dir=.dotfiles.git --work-tree=. checkout -f

    # Initialize submodules
    git --git-dir=.dotfiles.git submodule update --init --recursive
    git --git-dir=.dotfiles.git --work-tree=. submodule update --init --recursive
  12. bewuethr revised this gist Aug 12, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ cat <<-EOF > .dotfiles.git/info/sparse-checkout
    EOF

    # Check out files - this overwrites existing files
    git --git-dir="$HOME/.dotfiles.git" --work-tree="$HOME" checkout -f
    git --git-dir=.dotfiles.git checkout -f

    # Initialize submodules
    git df submodule update --init --recursive
    git --git-dir=.dotfiles.git submodule update --init --recursive
  13. bewuethr revised this gist Aug 12, 2019. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -4,19 +4,17 @@
    git clone --bare [email protected]:bewuethr/dotfiles.git .dotfiles.git

    # Set local repo configuration
    cd .dotfiles.git || exit 1
    git config user.name bewuethr
    git config user.email [email protected]
    git config status.showUntrackedFiles no
    git config core.sparseCheckout true
    cat <<-EOF > info/sparse-checkout
    git -C .dotfiles.git config user.name bewuethr
    git -C .dotfiles.git config user.email [email protected]
    git -C .dotfiles.git config status.showUntrackedFiles no
    git -C .dotfiles.git config core.sparseCheckout true
    cat <<-EOF > .dotfiles.git/info/sparse-checkout
    /*
    !README.md
    !LICENSE
    EOF

    # Check out files - this overwrites existing files
    cd ..
    git --git-dir="$HOME/.dotfiles.git" --work-tree="$HOME" checkout -f

    # Initialize submodules
  14. bewuethr revised this gist Aug 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dfinit
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ EOF

    # Check out files - this overwrites existing files
    cd ..
    git df checkout -f
    git --git-dir="$HOME/.dotfiles.git" --work-tree="$HOME" checkout -f

    # Initialize submodules
    git df submodule update --init --recursive
  15. bewuethr revised this gist Aug 12, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ EOF

    # Check out files - this overwrites existing files
    cd ..
    git dft checkout -f
    git df checkout -f

    # Initialize submodules
    git dft submodule update --init --recursive
    git df submodule update --init --recursive
  16. bewuethr created this gist Aug 12, 2019.
    23 changes: 23 additions & 0 deletions dfinit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/usr/bin/env bash

    # Clone repository as bare repository
    git clone --bare [email protected]:bewuethr/dotfiles.git .dotfiles.git

    # Set local repo configuration
    cd .dotfiles.git || exit 1
    git config user.name bewuethr
    git config user.email [email protected]
    git config status.showUntrackedFiles no
    git config core.sparseCheckout true
    cat <<-EOF > info/sparse-checkout
    /*
    !README.md
    !LICENSE
    EOF

    # Check out files - this overwrites existing files
    cd ..
    git dft checkout -f

    # Initialize submodules
    git dft submodule update --init --recursive