Outils d'utilisateurs

Outils du Site


Git CheatSheet

A Quick Git reminder. This will grow as I go.


Teaching Git Who It's Dealing With

$ git config --global user.name "Olivier Mehani"
$ git config --global user.email me@example.com

Coloured Output

$ git config --global color.ui auto

More Insight When Resolving Merges

As explained here, a diff3 style for conflicts shows both parents, thus allowing to understand the conflict and fix it better. Also, vimdiff is good.

$ git config --global merge.conflictstyle diff3
$ git config --global merge.tool vimdiff

List Tags Containing a Specific Commit

Using git tag.

$ git tag --contains COMMIT
[tag list]

New Branch Without History

The easiest (i.e. almost one line) solution can be seen here.

$ git symbolic-ref HEAD refs/heads/newbranch
$ rm .git/index

It works by pointing HEAD to a non-existing branch, and removing the current index so nothing is staged yet.

It might be better to use git checkout –orphan …; git rm -rf ..

Merge a Branch as a Subdirectory of Another

As explained in git-filter-branch(1), via Zrajm.

$ SUBDIR_NAME="the\/subdir"
$ BRANCH_NAME=newbranch
$ git filter-branch --index-filter \
    'git ls-files -s | \
        sed "s-\t-&'"$SUBDIR_NAME"'/-" | \
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && \
    ' "$BRANCH_NAME"
tips/git.txt · Dernière modification: 2013/11/15 05:06 (modification externe)