Skip to content

Commit

Permalink
Setup git-lfs
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Jul 16, 2023
1 parent 166379c commit fe9e2e1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 41 deletions.
81 changes: 44 additions & 37 deletions home/dot_gitconfig.tmpl
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
[user]
name = {{ .name }}
email = {{ .email }}
name = {{ .name }}
email = {{ .email }}

[core]
editor = {{ .editor }}
[rebase]
autoStash = true
[merge]
autoStash = true
[push]
autoSetupRemote = true
[diff]
tool = vscode
editor = {{ .editor }}

[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
tool = vscode
cmd = code --wait --diff $LOCAL $REMOTE

[mergetool "vscode"]
cmd = code --wait $MERGED
cmd = code --wait $MERGED

[diff]
tool = vscode

[merge]
autoStash = true
tool = vscode

[rebase]
autoStash = true

[push]
autoSetupRemote = true

[alias]
s = status
c = commit
ca = commit --amend
caa = ca -a
cane = ca --no-edit
caane = cane -a
co = checkout
cob = checkout -b
cp = cherry-pick
get-default-branch = "!f() { set -ex; remote="${1:-"origin"}"; git ls-remote --symref "${remote}" HEAD | sed -n 's,^ref: refs/heads/\\(\\S*\\)\\tHEAD$,\\1,p'; }; f"
fully-clean = "!f() {set -ex; default_branch="$(git get-default-branch)"; git checkout "${default_branch}"; git fetch origin "${default_branch}"; git clean -fdx; }; f"
get-current-branch = "!git branch --show-current | grep ."
get-remote-for-branch = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\\(\\S*\\)/'"${branch}"'$,\\1,p'; }; f"
rr = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git reset --hard "${remote}/$branch"; }; f"
pfor = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/for/${branch}"; }; f"
psfor = "!f() { set -ex; git caane; git pfor "$@"; }; f"
pdraft = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/drafts/${branch}"; }; f"
psdraft = "!f() { set -ex; git caane; git pdraft "$@"; }; f"
plr = pull --rebase
prune-refs = fetch --prune --prune-tags
hist = log --pretty=format:'%C(yellow)%h%Creset %ad | %s%d %Cgreen[%an]%Creset' --graph --date=short
apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f"
s = status
c = commit
ca = commit --amend
caa = ca -a
cane = ca --no-edit
caane = cane -a
co = checkout
cob = checkout -b
cp = cherry-pick
get-default-branch = "!f() { set -ex; remote="${1:-"origin"}"; git ls-remote --symref "${remote}" HEAD | sed -n 's,^ref: refs/heads/\\(\\S*\\)\\tHEAD$,\\1,p'; }; f"
fully-clean = "!f() {set -ex; default_branch="$(git get-default-branch)"; git checkout "${default_branch}"; git fetch origin "${default_branch}"; git clean -fdx; }; f"
get-current-branch = "!git branch --show-current | grep ."
get-remote-for-branch = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\\(\\S*\\)/'"${branch}"'$,\\1,p'; }; f"
rr = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git reset --hard "${remote}/$branch"; }; f"
pfor = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/for/${branch}"; }; f"
psfor = "!f() { set -ex; git caane; git pfor "$@"; }; f"
pdraft = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/drafts/${branch}"; }; f"
psdraft = "!f() { set -ex; git caane; git pdraft "$@"; }; f"
plr = pull --rebase
prune-refs = fetch --prune --prune-tags
hist = log --pretty=format:'%C(yellow)%h%Creset %ad | %s%d %Cgreen[%an]%Creset' --graph --date=short
apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f"
8 changes: 8 additions & 0 deletions root/.chezmoiexternal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
url: "https://github.com/docker/compose-switch/releases/download/v{{ template "get-github-latest-version" list "docker/compose-switch" $cache }}/docker-compose-linux-{{ .chezmoi.arch }}"
executable: true

"usr/local/bin/git-lfs":
type: file
url: "https://github.com/git-lfs/git-lfs/releases/download/v{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}/git-lfs-linux-{{ .chezmoi.arch }}-v{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}.tar.gz"
filter:
command: tar
args: ["-x", "-z", "-O", "git-lfs-{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}/git-lfs"]
executable: true

{{ if .is_wsl }}
"usr/bin/docker-credential-wincred.exe":
type: file
Expand Down
14 changes: 10 additions & 4 deletions root/etc/gitconfig.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[credential]
helper = /usr/local/bin/git-credential-manager
{{ if .is_wsl -}}
{{- if .is_wsl }}
credentialStore = wincredman
{{ else if and .is_gnome (not .is_headless) -}}
{{- else if and .is_gnome (not .is_headless) }}
credentialStore = secretservice
{{ else -}}
{{- else }}
credentialStore = plaintext
{{ end -}}
{{- end }}

[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true

0 comments on commit fe9e2e1

Please sign in to comment.