View on GitHub

Random technical notes

Random technical notes

Common

Tools

Learning

Get settings

git config --global --list

Clean credential settings

git config --local credential.helper ""
# or set wincred type
git config --global credential.helper wincred

Configure user name

Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

.gitconfig

Edit the .gitconfig file:

git config --global -e

Example of the file:

[user]
    name = XXX
    email = XXX
[credential]
    helper = manager
    #helper = wincred
    #git config --global credential.helper wincred
[core]
    autocrlf = true
[push]
    default = tracking
[branch]
    autosetuprebase = always
[pull]
    rebase = false

Line endings in Git

The key to dealing with line endings is to make sure your configuration is committed to the repository, using .gitattributes. For most people, this is as simple as creating a file named .gitattributes at the root of your repository that contains one line:

* text=auto

With this set, Windows users will have text files converted from Windows style line endings (\r\n) to Unix style line endings (\n) when they’re added to the repository.

Why not core.autocrlf?

Originally, Git for Windows introduced a different approach for line endings that you may have seen: core.autocrlf. This is a similar approach to the attributes mechanism: the idea is that a Windows user will set a Git configuration option core.autocrlf=true and their line endings will be converted to Unix style line endings when they add files to the repository.

The difference between these two options is subtle, but critical: the .gitattributes is set in the repository, so its shared with everybody. But core.autocrlf is set in the local Git configuration. That means that everybody has to remember to set it, and set it identically.

Source: Git for Windows: Line Endings

Additional:

Git Features

Git Subtree

Commands

git subtree push --prefix folder-name/CommonWidgets https://github.com/repo.git master
# predefined
git remote add -f CommonWidgets  https://github.com/repo.git

Update git repos

@echo off

cls

echo. Remove Obj and Bin folders
rem for /d /r . %%d in (bin,obj) do @if exist "%%d" rmdir /s /q "%%d"
for /d /r . %%d in (bin,obj) do @if exist "%%d" rmdir /s /q "%%d"

echo. Refresh repos
for /f "tokens=*" %%d in ('dir /AD /B /ON') do @call :UpdateRepo "%%d"

echo. Done!
goto :EOF

:UpdateRepo [folder]
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
set repo=%~1
echo.
echo.
echo. Repository '%repo%'
cd "%repo%"
rem git checkout master
git reset --hard HEAD~1
git clean -xdf
git pull
cd ..
goto :EOF