Git - nimrody/knowledgebase GitHub Wiki

  • Using git diff for non-repositories git diff --no-index dira dirb

  • Git diff show only modified files - not new files git diff --diff-filter=M

  • Alibaba - detailed explanation of underlying data structures and principles of git

  • Setup remote branch

    $ git remote add nimrody nimrody.com:prj/tensera/mysql-monitor $ git push --set-upstream nimrody master

  • worktree

  • Add worktree to track remote branch

    git worktree add -b rep ../rep origin/rep

  • Search all history for a regular expression

    git rev-list --all

    | xargs git grep expression git grep $(git rev-list --all)

    Use -e <expr> --or -e <expr2> to search for two regular expressions

Ignoring committed files

git update-index --assume-unchanged <filename>

And to show the ignored files:

git ls-files -v | grep '^[[:lower:]]'

Rebase

  • git-svn rebase git checkout --our gets the svn version, git checkout --theirs gets our local changes

Managing multiple identities (work, personal, etc.):

  • See discussion here:

    Recommended approach: Use includeIf. In the local ~/.gitconfig

    [user]
        name = Me Myself
        email = [email protected]
        signingkey = D34DB44F
    
    [includeIf "gitdir:~/src/github.com/work_org/"]
        path = ~/.gitconfig_work
    

    Then in ~/.gitconfig_work:

    [user]
        name = Me Myself
        email = [email protected]
        signingkey = D34DC0D4
    
    [core]
        sshCommand = ssh -i ~/.ssh/work_ed25519
    
⚠️ **GitHub.com Fallback** ⚠️