forked from kontur-courses/git-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply-gitconfig-for-win.cmd
62 lines (49 loc) · 2.28 KB
/
apply-gitconfig-for-win.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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