Skip to content

Commit

Permalink
Autoconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe committed Oct 8, 2021
1 parent f763f5f commit 24be26a
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitconfig-for-nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[merge]
tool = vscode
[mergetool]
keepbackup = false
[diff]
tool = vscode
guitool = vscode
[core]
autocrlf = input
[pull]
ff = only
rebase = false
[fetch]
prune = false
[rebase]
autoStash = false
[difftool "vscode"]
path = code
cmd = code --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
path = code
cmd = code --wait $MERGED
[credential]
helper = manager
[alias]
it = !git init && git commit -m 'Initial commit' --allow-empty
st = status -sb
call = !git add . && git commit -m
commend = commit --amend --no-edit
graph = log --oneline --decorate --graph --all
to = checkout
pushup = push -u origin HEAD
please = push --force-with-lease
puff = pull --ff-only
pure = pull --rebase --autostash
undo = reset --soft HEAD^

36 changes: 36 additions & 0 deletions .gitconfig-for-win
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[merge]
tool = vscode
[mergetool]
keepbackup = false
[diff]
tool = vscode
guitool = vscode
[core]
autocrlf = true
[pull]
ff = only
rebase = false
[fetch]
prune = false
[rebase]
autoStash = false
[difftool "vscode"]
path = code
cmd = code --wait --diff $LOCAL $REMOTE
[mergetool "vscode"]
path = code
cmd = code --wait $MERGED
[credential]
helper = manager
[alias]
it = !git init && git commit -m 'Initial commit' --allow-empty
st = status -sb
call = !git add . && git commit -m
commend = commit --amend --no-edit
graph = log --oneline --decorate --graph --all
to = checkout
pushup = push -u origin HEAD
please = push --force-with-lease
puff = pull --ff-only
pure = pull --rebase --autostash
undo = reset --soft HEAD^
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Коллекция полезных .gitignore от GitHub: https://github.com/github/gitignore

# Игнорирование всех markdown-файлов:
*.md

# Исключение из игнорирования конкретного файла:
!init.md
18 changes: 18 additions & 0 deletions apply-gitconfig-for-nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
git config --local include.path "../.gitconfig-for-nix"

# setting editor for commits
git config --local core.editor nano

# setting anonymous name and email if not configured by user
GitUserEmail=$(git config --get user.email)
if [[ "$GitUserEmail" == "" ]]; then
git config --local user.email "[email protected]"
fi
GitUserName=$(git config --get user.name)
if [[ "$GitUserName" == "" ]]; then
git config --local user.name "John Doe"
fi

echo "Configuration is done"
sleep 3
62 changes: 62 additions & 0 deletions apply-gitconfig-for-win.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@echo off

set GIT=git

%GIT% --help > nul

if %errorlevel% neq 0 (
set GIT="%ProgramFiles%\Git\bin\gi.exe"
)

%GIT% --help > nul

if %errorlevel% neq 0 (
color 0c
echo.
echo.
echo "Git is not configured properly... Ask for help!"
pause
exit
)

REM setting editor for commits
%GIT% config --local core.editor notepad

REM including predefined config
%GIT% config --local include.path "../.gitconfig-for-win"

REM setting up absolute path to visual studio code
if exist "%ProgramFiles(x86)%\Microsoft VS Code\Code.exe" (
%GIT% config --local difftool.vscode.path "%ProgramFiles(x86)%\Microsoft VS Code\Code.exe"
%GIT% config --local difftool.vscode.cmd "%ProgramFiles(x86)%\Microsoft VS Code\Code.exe --wait --diff $LOCAL $REMOTE"
%GIT% config --local mergetool.vscode.path "%ProgramFiles(x86)%\Microsoft VS Code\Code.exe"
%GIT% config --local mergetool.vscode.cmd "%ProgramFiles(x86)%\Programs\Microsoft VS Code\Code.exe --wait $MERGED"
)
if exist "%ProgramFiles%\Microsoft VS Code\Code.exe" (
%GIT% config --local difftool.vscode.path "%ProgramFiles%\Microsoft VS Code\Code.exe"
%GIT% config --local difftool.vscode.cmd "%ProgramFiles%\Microsoft VS Code\Code.exe --wait --diff $LOCAL $REMOTE"
%GIT% config --local mergetool.vscode.path "%ProgramFiles%\Microsoft VS Code\Code.exe"
%GIT% config --local mergetool.vscode.cmd "%ProgramFiles%\Programs\Microsoft VS Code\Code.exe --wait $MERGED"
)
if exist "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe" (
%GIT% config --local difftool.vscode.path "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe"
%GIT% config --local difftool.vscode.cmd "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe --wait --diff $LOCAL $REMOTE"
%GIT% config --local mergetool.vscode.path "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe"
%GIT% config --local mergetool.vscode.cmd "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe --wait $MERGED"
)

REM setting anonymous name and email if not configured by user
for /f %%i in ('git config --get user.email') do set GitUserEmail=%%i

if [%GitUserEmail%] == [] (
%GIT% config --local user.email "[email protected]"
)

for /f %%i in ('git config --get user.name') do set GitUserName=%%i

if [%GitUserName%] == [] (
%GIT% config --local user.name "John Doe"
)

echo Configuration is done
pause

0 comments on commit 24be26a

Please sign in to comment.