Monthly Archives: July 2011

How to show which commits Git will push or merge

To show which commits Git will push or merge, these are the aliases you need in your Git configuration file (e.g. C:\cygwin\home\<user>\.gitconfig or <project>/.git/config). The explanation is below.

[alias]
    # -M                 Detect and report renames for each commit.
    # --name-status      Show only names and status of changed files.
    # --abbrev-commit    Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix.
    l = log -M --name-status --abbrev-commit

    # --oneline          This is a shorthand for "--pretty=oneline --abbrev-commit" used together.
    l1 = log --oneline

    # log commits-to-push
    lctp  = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l $REMOTE_SERVER/$REMOTE_BRANCH..HEAD\"; \
            echo $COMMAND; \
            $COMMAND"
    lctp1 = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l1 $REMOTE_SERVER/$REMOTE_BRANCH..HEAD\"; \
            echo $COMMAND; \
            $COMMAND"

    # log commits-to-merge
    # do not forget to execute "git fetch" first
    lctm  = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l HEAD..$REMOTE_SERVER/$REMOTE_BRANCH\"; \
            echo $COMMAND; \
            $COMMAND"
    lctm1 = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l1 HEAD..$REMOTE_SERVER/$REMOTE_BRANCH\"; \
            echo $COMMAND; \
            $COMMAND"

Read more »

How to configure Git on Windows (under Cygwin) to use Beyond Compare 3

Let’s get to the point.
To configure Git on Windows (under Cygwin) to use Beyond Compare 3, you should have the following in your .gitconfig file (e.g. C:\cygwin\home\<user>\.gitconfig):

[[diff]]
    tool = mybc3
[difftool "mybc3"]
    cmd = \"c:/program files/beyond compare 3/BComp.com\" \"$(cygpath -w \"$LOCAL\")\" \"$(cygpath -w \"$REMOTE\")\" /lefttitle=\"$(cygpath -w \"$LOCAL\")\" /righttitle=\"$(cygpath -w \"$REMOTE\")\" /leftreadonly /rightreadonly
[difftool]
    prompt = false
[merge]
    tool = mybc3
[mergetool "mybc3"]
    cmd = \"c:/program files/beyond compare 3/BComp.com\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" /lefttitle=\"$LOCAL\" /righttitle=\"$REMOTE\" /centertitle=\"$BASE\" /outputtitle=\"$MERGED\" /leftreadonly /rightreadonly /centerreadonly
    keepBackup = false
    trustExitCode = true
[mergetool]
    prompt = false

Read more »